Commit-editmsg Info

: Lines starting with # are instructions and status updates. Git automatically discards these lines when saving your commit.

If you're working on a commit and want to use "interesting text" as your commit message, you would:

: You type your message, save the file, and close the editor.

: Keep the summary line under 50 characters. Keep body paragraphs wrapped tightly at 72 characters. This preserves clean readability in terminal logs ( git log ) and web interfaces like GitHub or GitLab.

Add feature to display interesting text

show you which files are staged for commit, which are unstaged, and helpful reminders that "empty messages abort the commit." These comments are automatically stripped out by Git and will not appear in your final history. Why It Matters Using this file instead of the quick -m "message"

: You can easily separate your commit into a short summary line (under 50 characters), a blank line, and a detailed explanatory paragraph.

: If you close the file without saving text, or leave it completely empty, Git cancels the commit. The Anatomy of a COMMIT-EDITMSG File

Improving Your Commit Message with the 50/72 Rule - DEV Community COMMIT-EDITMSG

You want every commit message to follow the Conventional Commits standard (e.g., feat: add login , fix: resolve null pointer ).

Refactor commit message handling and improve formatting

One of the most common frustrations for developers is losing a commit message due to an unexpected error. The next time you find yourself staring at a blank commit screen after a failed attempt, remember the COMMIT_EDITMSG file.

This is a lifesaver. It means you won't lose a carefully crafted commit message just because you forgot to stage a file. You can fix the problem and run git commit again. When you do, Git will open the editor with your previously saved message already in the file, ready to be used or modified. This behavior existed from the early days of Git and has been a deliberate feature, even when parts of Git were rewritten from shell script to C language. : Lines starting with # are instructions and status updates

If you did not configure an editor and ran git commit , you are likely staring at a Vim interface.

The existence of COMMIT_EDITMSG is a technical detail, but its purpose is purely practical: to facilitate the writing of a . A great commit message is arguably as important as the code change itself. It serves as documentation for your future self and for other developers.

Under normal, successful circumstances, Git cleans up after itself and removes the COMMIT_EDITMSG file.

TOP