During an interactive rebase (git rebase -i), you mark a commit as edit. Git stops and checks out that commit. You then run git reset HEAD^ to unstage files, stage partial changes, and run git commit. When you run git commit, the COMMIT_EDITMSG already contains the original commit message from the commit you are splitting. You can edit it to reflect the new, smaller change.
Many development environments and Git GUIs provide tools for editing commit messages, making the process more user-friendly. Additionally, linters and automated tools can check commit messages for adherence to project standards.
When you run git commit, Git opens your text editor (Vim, Nano, VS Code, etc.) and asks for a commit message.
What actually happens under the hood:
| Problem | Example | Fix | |---------|---------|-----| | Empty or missing | (no body) | Add why and how for non-obvious changes | | Just repeats subject | “Fix login bug – fixed the login bug” | Delete redundancy | | No reasoning | “Changed max length from 50 to 100” | “Increase max length to 100 because API now accepts up to 100 chars” | | Internal references missing | “Fixes issue” | “Fixes #427 – rate limiting on mobile” | | No “why” for breaking changes | “Changed config format” | “BREAKING CHANGE: config uses YAML instead of JSON – migration script in /docs” |
This is the most common "power user" scenario.
Scenario: You spent 10 minutes writing a detailed commit message in Vim. You save and quit, but Git aborts the commit because you forgot to stage a file (e.g., nothing to commit). COMMIT-EDITMSG
The Panic: You think your message is gone.
The Solution: Your message is safely stored in .git/COMMIT_EDITMSG. You can fix your staging area and then run:
git commit -F .git/COMMIT_EDITMSG
This tells Git to take the message directly from that file, saving you from rewriting it. During an interactive rebase ( git rebase -i
You saved an empty file, or a file with only comments (#). Git reads COMMIT-EDITMSG, strips comments, and sees nothing. Fix: Run git commit again and write a message.
A commit-msg hook can read .git/COMMIT_EDITMSG, validate its content (e.g., enforce Conventional Commits, require a body), and exit non-zero to abort the commit.
Example commit-msg hook snippet (bash):
#!/bin/sh
MSG_FILE="$1" # Git passes .git/COMMIT_EDITMSG as $1
if ! head -1 "$MSG_FILE" | grep -qE "^(feat|fix|docs): "; then
echo "ERROR: Commit message must follow Conventional Commits format"
exit 1
fi
In your default editor, COMMIT-EDITMSG usually has a subtle vertical line at column 50 or 72. This is not a coincidence.
A raw COMMIT-EDITMSG session forces you to adhere to this format, resulting in beautiful, git log --oneline and git shortlog friendly history.

This website may contain nudity and sexuality, and is intended for a mature audience.
You must be 18 or older to enter.