Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git: merge branch and use meaningful merge commit message?

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?

like image 602
kakyo Avatar asked Feb 21 '13 15:02

kakyo


People also ask

Can we commit in merged branch?

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.

How do I change a commit message after merge?

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).


1 Answers

Just pass the -m parameter to the merge command:

$ git merge other-branch -m "Commit Message" 
like image 193
Joe Zim Avatar answered Sep 20 '22 15:09

Joe Zim