In the world of Git, much of the spotlight falls on commands like commit , push , merge , and rebase . Developers boast about their aliases, their branching strategies, and their elegant use of interactive rebasing. Yet, nestled quietly in the .git folder of every repository lies a humble, often-overlooked file: COMMIT-EDITMSG .
git config --global commit.template ~/.gitmessage.txt Create ~/.gitmessage.txt : COMMIT-EDITMSG
Your commit-msg hook can read .git/COMMIT_EDITMSG and reject the commit if it doesn't match the regex: In the world of Git, much of the
Located in .git/hooks/commit-msg (or .git/hooks/commit-msg.sample to start), this script can read, validate, or even modify the COMMIT-EDITMSG file before the commit is finalized. You want every commit message to follow the Conventional Commits standard (e.g., feat: add login , fix: resolve null pointer ). git config --global commit