我有几个回购,我想合并成一个新的主回购,所有这些回购有独特的历史(绝对没有共同承诺之间) 。我创建了新的主仓库,在其他每个仓库上创建了一个分支,并将每个分支推送到主仓库。现在在master_repo中,将每个分支合并到master分支中都不会产生使用git merge -s和我们的简单git合并(我已经从头开始尝试)的冲突......但是我无法合并这些尝试从其他分支进入主分支的文件夹。我相信问题的一部分是没有共同的祖先承诺。我可以重现该问题如下:git合并工作从多个回购没有共同的祖先到新的回购
目录结构设置test_merge内: master_repo(与文件夹01) other_repoA(与文件夹03) other_repoB(与文件夹01和09)
,然后在Cygwin中终端( “...”=裁剪终端的消息):
$ cd master_repo/
$ git init
Initialized empty Git repository in .../test_merge/master_repo/.git/
添加文件与COMMITING ON master_repo硕士BRANCH
$ echo "text in file01" > 01/file01
$ git add *
warning: LF will be replaced by CRLF in 01/file01.
The file will have its original line endings in your working directory.
$ git commit -m "master_repo: first commit"
[master (root-commit) ...blah, blah...
1 file changed, 1 insertion(+)...blah, blah
添加文件,COMMITING ON other_repoA的主分支,增加新分支,推新分支master_repo
$ cd ../other_repoA
$ git init
Initialized empty Git repository...blah,blah
$ echo "text in file03" > 03/file03
$ git add *
...
$ git commit -m "other_repoA: first commit"
...
$ git checkout -b branchA
...
$ git status
On branch branchA
nothing to commit, working directory clean
$ git push ../master_repo branchA
To ../master_repo
* [new branch] branchA -> branchA
添加文件,COMMITING ON other_repoB的主分支,增加新分支,推新分支master_repo
$ cd ../other_repoB
$ git init
...
$ echo "text in file01 from other_repoB" > 01/file01
$ echo "text in file09 from other_repoB" > 09/file09
$ git add *
$ git commit -m "other_repoB: first commit"
...
$ git checkout -b branchB
...
$ git status
On branch branchB
nothing to commit, working directory clean
$ git push ../master_repo branchB
To ../master_repo
* [new branch] branchB -> branchB
一看master_repo
$ cd ../master_repo
$ git status
On branch master
nothing to commit, working directory clean
$ git branch
branchA
branchB
* master
$ ls
01
$ git checkout branchA
Switched to branch 'branchA'
$ ls
03
$ git checkout branchB
Switched to branch 'branchB'
$ ls
01 09
MERGE尝试:注意是c ontent分支机构A和B似乎被忽略
$ git checkout master
Switched to branch 'master'
$ git merge -s ours branchA
$ ls
01
$ git merge -s ours branchB
Merge made by the 'ours' strategy.
$ ls
01
$ cat 01/file01
text in file01
$ git checkout branchB
Switched to branch 'branchB'
$ ls
01 09
$ cat 01/file01
text in file01 from other_repoB
最终的结果,我想看到的是文件夹03和09加追加到01/file01的master_repo和“从other_repoB”。我正在寻找甚至可能使用git(而不是手动复制任何东西)?
合并分支B后branchA的内容是什么? –
branchA内容是包含“文件03中的文本”的03/file03。换句话说,master_repo中的branchA的内容与合并后的other_repoA的branchA的内容完全相同。为了澄清,branchA和branchB没有合并在一起;但是这两个分支都被合并到master_repo的master分支中(当然,最终结果并不理想 - master没有来自branchA和branchB的所有文件夹和文件)。感谢您尝试帮助。 – mangi07