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

后端 未结 7 1907
有刺的猬
有刺的猬 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  
    edit  
    

    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

提交回复
热议问题