簡體   English   中英

結合兩個 git 存儲庫的歷史

[英]Combining the history of two git repositories

I have git repo A. I also have git repo B, which is taken at some commit of repo A, but with the.git folder deleted and remade with git init . 已經在 B 中進行了一些提交。我現在想將 A 和 B 結合起來,以便 A 是開始的,然后在最后,B 的歷史開始。 我不關心哈希/父母/鏈接/等。 B 上的提交保持不變,我只需要 B 上的提交消息和文件更改保持不變,當組合兩個存儲庫時。

編輯:通過一些搜索,我發現了這個:

git clone B
cd B
git remote add old A
git remote update
git merge --strategy-option ours --allow-unrelated-histories <commit from when you forked>
git push --force

但是,這會創建一個Merge commit ,這對我來說是“骯臟的”——我想要一些線性的東西。

我找到了一個方法:

git clone B
cd B
git remote add old A
git remote update
git rebase -i old/master  --strategy-option theirs --onto <commit of A you want to merge into B>
git push -f

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM