Last active
August 20, 2021 00:57
-
-
Save dlbewley/90fa9c31d5847633c2186eb2b35715a1 to your computer and use it in GitHub Desktop.
Git pre-commit hook to allow tracking of example secrets but deny changes.
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 | |
# once you have tracked a file, .gitignore will not have an effect on it, even if you | |
# ignore the enclosing directory. | |
# be sure to commit example secrets before adding this to .git/hooks/pre-commit | |
# Redirect output to stderr. | |
exec 1>&2 | |
DENY_LIST="secrets|certs" | |
if test $(git diff --cached --name-only | grep -E "$DENY_LIST" | wc -l) != 0; then | |
echo "Error: Do not attempt to commit modified example secrets or add any more." | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment