[英]Rewriting git repo history without going through all commits
我想在git存儲庫中折疊一些丑陋的合並,而不必重新建立此后發生的所有提交。 例如:
* sha0 *
| ... ~50 commits | ... ~50 commits
* *
* sha1 --> * sha1
|\ * sha2
* * *
* |\ ...
|/ *
* |
* /
| /
|/
* sha2
*
...
這樣做的最佳方法是什么?
編輯:
在對其中一項答復提出建議后,我意識到我應該澄清一下:
最終,您將不得不重新定級。 一種簡單的方法是在sha1
處創建臨時分支,然后進行soft reset
,然后soft reset
基准。
git checkout -b temp_branch sha1
git reset --soft sha2
git commit -m <message>
git checkout master
git rebase --onto temp_branch sha1
git branch -d temp_branch
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.