Amending the message of Git commit made before a merge

You can try a git rebase --preserve-merges --interactive, with:

-p
--preserve-merges

Instead of ignoring merges, try to recreate them.

The BUG section of the man page includes:

The todo list presented by --preserve-merges --interactive does not represent the topology of the revision graph.
Editing commits and rewording their commit messages should work fine, but attempts to reorder commits tend to produce counterintuitive results.


As jthill's comment describes (since -p will better preserve merges if conflict resolutions were recorder):

You can retroactively light rerere for a merge:

git config rerere.enabled true
git checkout $merge^1

git merge $merge^2
# for Windows: 
# git merge $merge^^2

git read-tree --reset -u $merge
git commit -m-
git checkout @{-1}

As noted by Soufiane Roui in the comments:

For Windows CMD users, use double caret to point for parents of the merge commit (e.g $merge^^1 instead of $merge^1).
Because the caret is considered as an escape character.