This repo currently contains just one git hook - commit-msg, which checks that your commit message obeys 5 of the 7 rules of the 7 rules for commit messages (all except rules 5 and 7).
- Separate subject from body with a blank line
- Limit the subject line to 50 characters
- Capitalize the subject line
- Do not end the subject line with a period
- Use the imperative mood in the subject line
- Wrap the body at 72 characters
- Use the body to explain what and why vs. how
I found this repo useful in creating the repo here, which is a simplified version.
To "install" the commit-msg git hook, you can either clone this repo, run bash install-commit-msg.sh in the root of the cloned repo and then change the name of the repo and delete the .git file and any other remaining files to start a repo from scratch, OR if you have an existing repo you want to add this git-hook to, then download the commit-msg file, place it in .git/hooks/ and ensure it is executable by running chmod +x .git/hooks/commit-msg (this is basically what is done in the install-commit-msg.sh file).
## Test install You can now run
echo "testing" >> test.txt
git add test.txt
git commit -m "This is a commit message that is longer than the 50 character rule for the subject line"
and the commit-msg hook should prohibit that commit being allowed as it violates rule 2.