Last active
September 1, 2016 08:26
-
-
Save NxSoftware/8e1265bb7542ad4e5a1f1ce074fba830 to your computer and use it in GitHub Desktop.
git pre-commit hook to prevent committing files that contain a certain string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
git diff-index --name-status --cached HEAD -- | cut -c3- | while read FILE | |
do | |
if git diff --cached "$FILE" | grep -q "^+[^+].*// NOCOMMIT"; then | |
echo $FILE ' contains a NOCOMMIT string!' | |
exit 1 | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment