Created
February 9, 2018 23:10
-
-
Save jdmallen/d4f1ba1aec6db3a1d4d039b2bbce9dbc to your computer and use it in GitHub Desktop.
Handy git pre-compile hook to prevent yourself from committing passwords
This file contains hidden or 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 | |
| # Save this file in your {repoRoot}/.git/hooks directory with the filename | |
| # 'pre-commit' (no extension), and replace the passwords with your own. Don't | |
| # worry: this file does not get committed. It exists only where you place it. | |
| # Fair warning, though: you are essentially saving your password in plaintext. | |
| # Ensure that you have other security measures in place to protect your data; | |
| # e.g., drive encryption, station locking, etc. | |
| . git-sh-setup # for die | |
| git diff-index -p -M --cached HEAD -- | grep '^+' | | |
| grep 'password1\|password2\|password3\|password4' && die Blocking commit \ | |
| because password detected in patch | |
| : |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment