By default, Git ignores lines starting with #. If your commit message needs to contain a hashtag (e.g., #coding), this causes issues. You can change the comment character in your global config:
git config --global core.commentChar ";"
Now Git will ignore lines starting with ; and leave your # lines alone in the final commit.
Improve commit message standards
* Introduce standardized commit message template
* Update contribution guidelines with best practices
* Include examples for clearer understanding
The file COMMIT_EDITMSG is a temporary text file created by Git to store your commit message during the editing process.
When you run git commit without the -m flag, Git opens your default text editor and creates this file in the .git/ directory. It contains any pre-filled comments (which Git strips out later) and is where you type your summary and description.
Location: Found at .git/COMMIT_EDITMSG within your repository. COMMIT-EDITMSG
Function: It acts as a buffer. Once you save and close the editor, Git reads the text from this file to finalize the commit.
Aborting: If you close the file without saving or leave the message empty, Git will usually abort the commit.
Bypassing: You can avoid this file appearing by using git commit -m "your message". Best Practices for the Text
To write a professional commit message in this file, many developers follow the 50/72 rule: By default, Git ignores lines starting with #
Subject Line: Keep the first line under 50 characters and use the imperative mood (e.g., "Fix bug" instead of "Fixed bug").
Spacing: Leave a blank line between the subject and the body.
Body: Wrap the text at 72 characters and focus on why the change was made rather than how. Common Issues
If you have ever peeked into your project's .git folder, you have likely seen a file named COMMIT_EDITMSG. Most developers ignore it, but understanding this file is the secret to fixing failed commits, creating consistent templates, and automating your workflow. Now Git will ignore lines starting with ;
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:
The COMMIT-EDITMSG file is not just static text. Git provides a hook system—scripts that run at specific points in the commit lifecycle. The most important hook for our keyword is the commit-msg hook.
Located at .git/hooks/commit-msg (or in a shared template), this script runs after you have edited the COMMIT-EDITMSG file but before Git creates the commit.
Why is this revolutionary? Because you can programmatically validate or modify the commit message.