Progress:
TIER 2 · MODULE 48· Intermediate

git fmt-merge-msg

Used by git merge to compose its commit message.

🎯 What & why

git fmt-merge-msg builds the commit message git merge uses, reading the refs in FETCH_HEAD. You only invoke it directly when scripting custom merge flows.

🧠 Mental model

Plumbing: takes FETCH_HEAD lines on stdin, emits a merge commit subject and optional body. git merge calls it for you; scripts call it when they want to override the wording.

🛠️ Synopsis

git fmt-merge-msg [--log[=<n>] | --no-log] [--message <msg>] [-F <file>] < $GIT_DIR/FETCH_HEAD

# Driven by config:
#   merge.log = false | <n>
#   merge.summary = (deprecated alias of merge.log)

🎚️ Switches & options

FlagWhat it does
--log[=<n>]Append shortlog of up to <n> commits (default 20) being merged
--no-logSuppress the shortlog body — subject only
--message <msg>Use <msg> as the subject instead of the default
-F <file>Read FETCH_HEAD-style input from <file> instead of stdin
merge.logConfig: same effect as --log for every merge
merge.summaryDeprecated alias of merge.log; still honored

💡 Use cases

🧪 Examples

Default message from FETCH_HEAD
git fmt-merge-msg < .git/FETCH_HEAD
Include shortlog of merged commits
git fmt-merge-msg --log=50 < .git/FETCH_HEAD
Always log shortlogs by default
git config --global merge.log true
Use as input to a low-level merge
git fmt-merge-msg < .git/FETCH_HEAD | git commit-tree $TREE -p HEAD -p $OTHER -F -

🎓 Recommendations

🪤 Common pitfalls

🔗 Related modules

📝 Quiz

Hit each option, then Check answers. Score is recorded; Next is always open.