简体   繁体   English

如何将现有的非空目录转换为生活在另一个目录中的现有非空git仓库的git分支

[英]How to turn an existing, non-empty directory into a git branch of an existing non-empty git repo living in another directory

I have two directories, A & B, which differ very little in their content. 我有两个目录,A和B,它们的内容差异很小。 A is already init'd into a git repo and has a number of local commits to its master branch. A已经初始化为git仓库,并且对其主分支有许多本地提交。 Directory B is not under SCM and it's basically just the result of manually copying all the files over from A (sans the .git directory), editing some of them, and adding some new ones. 目录B不在SCM下,它基本上只是从A(没有.git目录)手动复制所有文件,编辑其中一些文件并添加一些新文件的结果。 Now I want to make the contents of B a branch of the repo in A and, if possible, still host development of the new branch in directory B... but I have no idea how to accomplish that as I am a total git n00b, and don't quite yet understand its approach to SCM enough to find the answer on my own in the documentation. 现在我想让B的内容成为A中repo的一个分支,如果可能的话,仍然在目录B中主持开发新分支......但是我不知道如何实现它,因为我是一个总git n00b并且还没有完全理解它的SCM方法足以在文档中找到我自己的答案。 Any tips/pointers? 任何提示/指针? Thanks in advance! 提前致谢!

copy A/.git into B/.git. 将A / .git复制到B / .git中。 Then do what you normally would do for the branching. 然后做你通常会做的分支。

cd B
git branch dev
git commit -a

You can then sync changes like this: 然后,您可以同步这样的更改:

cd A
git pull ../B dev

or the other way around. 或者相反。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM