This Git pre-commit hook checks for the existence of the word "nocheckin" ($SEARCH_TARGET
) in staged source files,
then aborts the commit if any matches were found, with output of file path, line number and match preview.
This is inspired by Jonathan Blow's nocheckin setup with SVN, as seen on his programming sessions at Twitch and YouTube.
Credit to DustinGadal
on the r/Jai
subreddit for original implementation.
Tested on Linux and macOS.
Download the file from above.
Move the file and rename it to <repo>/.git/hooks/pre-commit
(or merge manually if you already have a pre-commit hook).
The file name has to be "pre-commit
" for Git to use it.
Once installed, it is compatible with the Github Desktop GUI as well.
CLI:
- Stage files with
git add <file> ...
- Attempt making a commit with
git commit ...
- Observe the commit failing with the appropriate output when at least one of the staged files contains a
nocheckin
.
GUI (Github Desktop)
- Mark some files for staging.
- Attempt commiting.
- Observe the commit failing with the appropriate output when a file contains a
nocheckin
.