The default git commit message for merge conflicts lists any files that were conflicts. However, it includes them as a comment with the # prefix. This means they’ll get stripped from the real commit message, by default. I like to keep them in the commit message, because it can useful to know which files were conficts later on. To do this, I would manually remove the comment prefix. Unitl now… TLDR: Use git commit --cleanup scissors, but the following example will explain how this works. I also answered this on Stack Overflow, but figured it would make a good blog post.

When you use git commit, there are different cleanup modes which determine how the message is automatically cleaned up, specified by the --cleanup option. Here’s an excerpt from the git-commit(1) man page:

       --cleanup=<mode>
           This option determines how the supplied commit message should be
           cleaned up before committing. The <mode> can be strip, whitespace,
           verbatim, scissors or default.

           strip
               Strip leading and trailing empty lines, trailing whitespace,
               commentary and collapse consecutive empty lines.

           whitespace
               Same as strip except #commentary is not removed.

           verbatim
               Do not change the message at all.

           scissors
               Same as whitespace except that everything from (and including)
               the line found below is truncated, if the message is to be
               edited. "#" can be customized with core.commentChar.

                   # ------------------------ >8 ------------------------

           default
               Same as strip if the message is to be edited. Otherwise
               whitespace.

           The default can be changed by the commit.cleanup configuration
           variable (see git-config(1)).

The default mode is essentially strip. Here’s an example of a commit message with a merge conflict using strip mode:

% git commit --cleanup strip 
Merge branch 'branch'

# Conflicts:
#       baz.txt
#       foo.txt
#
# It looks like you may be committing a merge.
# If this is not correct, please remove the file
#       .git/MERGE_HEAD
# and try again.


# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch master
# All conflicts fixed but you are still merging.
#
# Changes to be committed:
#       modified:   bar.txt
#       modified:   baz.txt
#       modified:   foo.txt
#

As you can see, it shows the list of file conflicts. But if you just accept the defult message, the real commit message will be:

% git log -1
commit 86cb4bbcc5f2ed54641a0f2a58a4b03bb73be0a3 (HEAD -> master)
Merge: efd152d 474a8f4
Author: Dave Dribin <dave@example.com>
Date:   Fri Oct 19 23:38:47 2018 -0500

    Merge branch 'branch'

It stripped every line with the comment prefix, so you get a nice short message. However, that handy list of conflicts is missing. If you want them included, you need to remove the comment prefix. Let’s try that again with scissors mode:

% git commit --cleanup scissors  
Merge branch 'branch'

# Conflicts:
#       baz.txt
#       foo.txt
# ------------------------ >8 ------------------------
# Do not modify or remove the line above.
# Everything below it will be ignored.
#
# It looks like you may be committing a merge.
# If this is not correct, please remove the file
#       .git/MERGE_HEAD
# and try again.


# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# On branch master
# All conflicts fixed but you are still merging.
#
# Changes to be committed:
#       modified:   bar.txt
#       modified:   baz.txt
#       modified:   foo.txt
#

This time, if you accept the default commit message, you get the following commit message:

% git log -1
commit 1eb84d98faf502e64f29ffca0766ad2e708aa61d (HEAD -> master)
Merge: efd152d 474a8f4
Author: Dave Dribin <dave@example.com>
Date:   Fri Oct 19 23:43:32 2018 -0500

    Merge branch 'branch'
    
    # Conflicts:
    #       baz.txt
    #       foo.txt

The list of conflicts is included, even though they still start with the # prefix. This works because it will keep everything before the special “scissors” line, including the conflict list, despite them having a comment prefix. I found this so useful that I’ve changed my default cleanup mode to scissors by setting commit.cleanup in my ~/.gitconfig.