3 回答

TA貢獻1805條經(jīng)驗 獲得超10個贊
發(fā)現(xiàn)對于一個大型存儲庫(> 5000次提交),filter-branch比rebase更好,原因有以下幾種:1)它更快2)當出現(xiàn)合并沖突時,它不需要人工干預。3)它可以重寫標簽 - 保留它們。請注意,filter-branch有效,因為對每個提交的內(nèi)容沒有任何疑問 - 它與此'rebase'之前完全相同。
我的步驟是:
# first you need a new empty branch; let's call it `newroot`
git symbolic-ref HEAD refs/heads/newroot
git rm --cached -r .
git clean -f -d
# then you apply the same steps
git commit --allow-empty -m 'root commit'
# then use filter-branch to rebase everything on newroot
git filter-branch --parent-filter 'sed "s/^\$/-p <sha of newroot>/"' --tag-name-filter cat master
請注意,'--tag-name-filter cat'選項意味著將重寫標記以指向新創(chuàng)建的提交。
- 3 回答
- 0 關(guān)注
- 1318 瀏覽
添加回答
舉報