Commit-editmsg – Top & Legit
Set a global template:
If your team follows specific commit message formats (e.g., Conventional Commits ), you can set up COMMIT_EDITMSG to act as a template. COMMIT-EDITMSG
# Please enter the commit message for your changes. Lines starting # with '#' will be ignored, and an empty message aborts the commit. # # On branch feature/user-auth # Changes to be committed: # modified: src/auth/login.js # new file: src/auth/session.js # # Changes not staged for commit: # modified: README.md # # --------------------------------------------------------- # diff --git a/src/auth/login.js b/src/auth/login.js # index 123abc..456def 100644 # --- a/src/auth/login.js # +++ b/src/auth/login.js # @@ -12,7 +12,9 @@ function validateUser(user) { # ... Set a global template: If your team follows
The existence of this file encourages developers to move away from "one-liner" commits and toward the industry-standard . According to many commit message guides , a well-structured message should have: # # On branch feature/user-auth # Changes to
git commit -m "Fix bug in login flow"
if ! grep -q -E "$pattern" "$message_file"; then echo "ERROR: Commit message does not follow Conventional Commits format." echo "Expected: <type>(<scope>): <subject>" echo "Example: feat(auth): add OAuth2 provider" exit 1 fi