我需要將兩個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
我已添加「塗漆解決方案」 –