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
Solution 1:
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.
Solution 2:
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
Solution 3:
Just set the editor to a command that does nothing:
GIT_EDITOR=true git commit