I want to correct a typo in a merge commit message in gitlab. The original branch doesn't exist anymore since it was deleted after merging. I can edit the squash commit message using its SHA and an interactive rebase:
git rebase -I b1c79640
However, this doesn't work with the merge commit message. The git graph looks as follows:
Could someone explain why I can't edit the message Merge branch 'feature...' but the 'Resolve "Experiment ...."' message? Also, how can I edit this message?
You need to add --rebase-merges
option to rebase merge commits as well. Quoting the --rebase-merges
documentation:
By default, a rebase will simply drop merge commits from the todo list, and put the rebased commits into a single, linear branch. With --rebase-merges, the rebase will instead try to preserve the branching structure within the commits that are to be rebased, by recreating the merge commits. Any resolved merge conflicts or manual amendments in these merge commits will have to be resolved/re-applied manually.
git rebase -i --rebase-merges b1c79640
Once the git-rebase-todo
file is opened in the editor, replace the -C
(upper case) option with -c
(lower case) in the merge commit line to edit its commit message.
...
# replace -C with -c
merge -c 19b5d7c my old commit message
...