Skip to content

fmt-merge-msg Git Command Guide

The git fmt-merge-msg command is used to produce a formatted commit message suitable for merge commits. It takes the list of merged objects and generates a message describing the merge, typically used internally by git merge but can be used standalone.

Terminal window
git fmt-merge-msg [-m <message>] [--into-name <branch>] [--log[=<n>] | --no-log] [-F <file>]
OptionDescription
—log[=]Include commit descriptions in message (default 20)
—no-logExclude commit descriptions
-m , —message Use custom message instead of branch names
—into-name Specify target branch name
-F , —file Read merged objects from file instead of stdin
—[no-]summaryDeprecated synonyms for —log/—no-log
ParameterDescription
(stdin)List of merged objects/commit IDs
Terminal window
git fmt-merge-msg < merge-refs.list

Generate merge commit message from list of refs in file.

Terminal window
cat refs.txt | git fmt-merge-msg --log

Generate merge message with one-line commit descriptions.

Terminal window
git fmt-merge-msg --log --message "Implement feature X"

Use custom message with commit descriptions.

Terminal window
git fmt-merge-msg --into-name main --log < merge-input.txt

Specify target branch name explicitly.

Terminal window
cat merge-refs | git fmt-merge-msg --log=10

Include only 10 commit descriptions in message.

Terminal window
echo -e "abc123\ndef456" | git fmt-merge-msg --no-log

Generate merge message without commit descriptions.

Terminal window
git fmt-merge-msg --log --message "Merge pull request" < merge-refs.txt

Generate message as used internally by git merge.

How do I generate a merge commit message with descriptions?

Section titled “How do I generate a merge commit message with descriptions?”

To include commit descriptions, use —log option:

Terminal window
git fmt-merge-msg --log < merge-ref-list

To use a custom message instead of branch names, use —message:

Terminal window
git fmt-merge-msg --message "Feature implementation" --log

How do I limit the number of commit descriptions?

Section titled “How do I limit the number of commit descriptions?”

To limit descriptions, specify a number with —log:

Terminal window
git fmt-merge-msg --log=5

To read from a file instead of stdin, use -F:

Terminal window
git fmt-merge-msg -F merge-refs.txt --log

To specify which branch is being merged into, use —into-name:

Terminal window
git fmt-merge-msg --into-name develop --log

What’s the difference between —log and —no-log?

Section titled “What’s the difference between —log and —no-log?”

—log includes one-line commit descriptions, —no-log only shows branch names but no individual commit details.

git merge calls fmt-merge-msg to format the commit message when completing a merge operation, passing appropriate options and merge information.

Can I suppress branch destination in messages?

Section titled “Can I suppress branch destination in messages?”

Configure merge.suppressDest to omit “into ” from messages for certain branch patterns.

Applications of the git fmt-merge-msg command

Section titled “Applications of the git fmt-merge-msg command”
  1. Scripting custom merge workflows with formatted messages
  2. Generating merge commit messages for automation tools
  3. Creating merge messages for complex multi-branch merges
  4. Debugging merge operations by examining generated messages
  5. Integrating merge message generation in CI/CD pipelines