我需要将两个Git存储库合并成一个全新的第三个存储库。 我按照以下说明操作,但结果不符合我的预期。 Merge two Git repositories without breaking file history合并两个Git存储库并保留主记录
看看这个:
主不神韵:。
- 是否有可能将所有内容合并到同一个主机上?
- 我想对主人有一个清晰的历史。
您可以自由使用我的例子库的在GitHub上:
这是我合并结果。
这是我想有这种情况:(涂液!)
如何我到了目前的情况:
# Assume the current directory is where we want the new repository to be created
# Create the new repository
git init
# Before we do a merge, we have to have an initial commit, so we'll make a dummy commit
dir > Read.md
git add .
git commit -m "initial commit"
# Add a remote for and fetch the old RepoA
git remote add -f RepoA https://github.com/DimitriDewaele/RepoA
# Merge the files from RepoA/master into new/master
git merge RepoA/master --allow-unrelated-histories
# Do the same thing for RepoB
git remote add -f RepoB https://github.com/DimitriDewaele/RepoB
# Merge the files from RepoB/master into new/master
git merge RepoB/master --allow-unrelated-histories
所有帮助表示赞赏!
UPDATE:ANSWER
正确的答案是衍合,而不是合并。
代码:
# Rebase the working branch (master) on top of repoB
git rebase RepoB/master
# Rebase teh working branch (master with RepoB) on top op repoA
git rebase RepoA/master
一个问题仍然存在。第二个回购失去了父母的观点。我张贴这是一个后续问题:Merge two Git repos and keep the history
你能更详细地解释你期待什么以及这有什么不同吗? –
你拥有一个主人的所有东西,我不确定你的意思是“对齐” - 尝试从你的本地移除RepoA和RepoB遥控器,然后看看图形的样子。 – Adrian
我已添加“涂漆解决方案” –