Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use the default git commit message after resolving merge conflicts?

After doing a merge and resolving conflicts, is there an "easy" way to just accept the default generated commit message from the command line? One of our developers will resolve all the conflicts, and then do a git commit -m"Merge Commit" which replaces the generated commit message that listed all the conflict files. I would like to have a different flag that would just take the current file without modification. I know there is a -F or --file= option, but that requires knowing the file name all the time.

Thank you

like image 252
yoyodyn Avatar asked Dec 19 '12 21:12

yoyodyn


People also ask

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


2 Answers

Per the docs, I just tried this simple command and it worked for me:

git commit --no-edit 

Afterward, run git log to confirm that the default message has been used.

like image 88
gMale Avatar answered Sep 19 '22 03:09

gMale


By default when a merge fails the commit message that was to be used is saved in a file in the git folder, usually .git/MERGE_MSG. After the conflicts are resolved running git commit will feed this saved message to the default editor.

If the message is not being picked up on its own it could be feed to the git command using the --file option, which reads the commit message from a file:

git commit --file .git/MERGE_MSG 
like image 32
Maic López Sáenz Avatar answered Sep 21 '22 03:09

Maic López Sáenz