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 before HEAD?
git rebase -i HEAD~5 doesn’t list the merge commits.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you add the
--preserve-mergesoption (or its synonym,-p) to thegit rebase -icommand then git will try to preserve the merges when rebasing, rather than linearizing the history, and you should be able to amend the merge commits as well:Note.
--perserve-mergeshas been deprecated in favour of--rebase-mergesas of git v2.22 (https://www.infoq.com/news/2019/07/git-2-22-rebase-merges/).