| Issue | Found | Recommended | |-------|-------|--------------| | Subject line length | >50 chars (e.g., 72 chars) | Max 50 characters | | Blank line after subject | Missing | Always include one | | Body line wrap | >72 chars | Wrap at 72 characters | | Trailing whitespace | Present | None allowed | | Imperative mood | “Fixed bug” (past tense) | “Fix bug” (imperative) |
Example of bad format:
Fixed the issue where login fails when user has a very long email address and also the session times out after 30 seconds and we need to handle that edge case properly
Example of good format:
Fix login timeout for long email addresses
This commit directly addresses the clarity, standardization, and utility of commit messages within our project, setting a solid foundation for future contributions and code management.
COMMIT_EDITMSG is a temporary file created by Git during the committing process. It resides in the .git directory of your project (at .git/COMMIT_EDITMSG).
Its primary purpose is to act as a staging ground for your commit message. When you run git commit (without the -m flag), Git opens this file in your default text editor, allowing you to write, review, and edit the message before the commit is finalized and saved to the database.
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).
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.
When you open COMMIT_EDITMSG, you typically see two sections: the Message Area (top) and the Metadata/Comments (bottom).
Example Content:
feat: Add user authentication logic
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch main
# Changes to be committed:
# modified: src/auth.py
# new file: src/user.py
#
# ------------------------ >8 ------------------------
# Do not modify or remove the line above.
# Everything below it will be ignored.
diff --git a/src/auth.py b/src/auth.py
index 83db48f..d substring 100644
--- a/src/auth.py
+++ b/src/auth.py
@@ -1,5 +1,6 @@
import os
...
If you are writing scripts that generate commits, you might want to programmatically construct a message.
Instead of constructing a massive string for git commit -m, you can write your message into .git/COMMIT_EDITMSG (or a temporary file) and run git commit -F <filename>.
Launch Editor: Git opens your configured editor with this file.
User Edits: You write your commit message. You may also delete all comment lines – Git will ignore any line starting with # when parsing the final message.
Save & Exit: You save the file and close the editor.
Read by Git: Git reads .git/COMMIT_EDITMSG.
Strip Comments: Git removes all comment lines (lines starting with #).
Validation:
Create Commit Object: Git creates a new commit object with that message.
Cleanup (optional but typical): Git may delete or overwrite COMMIT_EDITMSG after the commit succeeds. However, in many cases, the file persists with the last commit message until the next commit starts. Do not rely on it for permanent storage.
