我有一個分支,其他人很少提交。我對同一分支進行了更多更改。現在我正在使用以下命令將所有提交壓縮為一次提交。
git rebase -i HEAD~2
從顯示的提交串列中,將第一個提交從 pick 更改為第二個提交從 pick 改寫為 squash 然后將提交訊息修改為一些有意義的 msg git push --force
現在,當我在遙控器上看到作者/提交者姓名時,仍然顯示舊的作者姓名。由于我是最近的提交者,有什么辦法可以將這個名字改成我的名字嗎?
uj5u.com熱心網友回復:
最簡單的方法是使用以下--reset-author選項修改壓縮的提交:
當與使用
-C/-c/--amend后一個沖突的櫻桃挑,宣告所得的作者提交選項,或提交時現在屬于提交者。這也會更新作者時間戳。
在您的情況下,您可以在將所有提交壓縮為一個后簡單地執行此操作:
git commit --amend --no-edit --reset-author
這將設定當前user.name和user.email作為提交的作者。
uj5u.com熱心網友回復:
要重寫最后一次提交的作者,請在完成git commit --amend --no-edit --reset-author后運行git rebase。
如果要重寫所有重新提交的提交,請將選項附加--exec 'git commit --amend --reset-author --no-edit'到git rebase.
git rebase -i head~2 --exec 'git commit --amend --reset-author --no-edit'
待辦事項串列將擴展為
pick 001111 foo
exec git commit --amend --reset-author --no-edit
pick 002222 bar
exec git commit --amend --reset-author --no-edit
如果你想重寫一些 rebase 的提交,exec git commit --amend --reset-author --no-edit在你想要的提交條目下面手動添加。例如,
pick 001111 foo
pick 002222 bar
exec git commit --amend --reset-author --no-edit
pick 003333 baz
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/313220.html
標籤:混帐 git-squash
上一篇:如何診斷git提交歷史中的問題
