Git: How to edit/reword a merge commit's message?

后端 未结 7 1877
有刺的猬
有刺的猬 2020-12-07 08:40

How do I edit or reword a merge commit\'s message?

git commit --amend works if it\'s the last commit made (HEAD), but what if it comes befo

相关标签:
7条回答
  • 2020-12-07 09:40

    Use the --rebase-merges (or the shortened -r) flag:

    git rebase -i -r HEAD~5
    

    Then change the 'pick' text to 'edit' or 'reword' next to the commit to change:

    pick <commit-hash-to-leave> <message>
    edit <commit-hash-to-change> <message>
    

    The --rebase-merges flag replaces the deprecated --preserve-merges (or the shortened -p)

    Documentation: https://git-scm.com/docs/git-rebase#Documentation/git-rebase.txt--r

    0 讨论(0)
提交回复
热议问题