After I merge a feature branch back to main branch I usually need to do a merge commit by default. But I'd like to use the original commit messages from my feature branch in this commit instead of "merge branch XXX".
How should I do that?
Merging your branch into master is the most common way to do this. Git creates a new commit (M) that is referred to as a merge commit that results from combining the changes from your feature branch and master from the point where the two branches diverged.
For current Git versions (2020+), just do git rebase -i -r <parent> , then replace in the editor merge -C with merge -c . This will open the merge commit's message in the editor during rebasing, where you can change it (thanks to VonC for the hint).
Just pass the -m
parameter to the merge
command:
$ git merge other-branch -m "Commit Message"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With