Created
June 15, 2016 17:18
-
-
Save DiegoSalazar/0f4e81cb80c50128a890675b8d83bf4e to your computer and use it in GitHub Desktop.
git pre-commit hook to block changes containing the string debug in a ruby comment
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-sh-setup # for die | |
git-diff-index -p -M --cached HEAD -- | grep '^+' | grep -n '# debug' && die 'Blocking commit: debug detected in code' | |
: |
Thank you so much for writing this!
Your Gist is ranked #1 for the Google search:
git pre-commit block string
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Copy this file into your repo's
.git/hooks
directory and make it executable. When any change to your code is added that contains the string# debug
it will block the commit from happening.cd /path/to/your/repo/.git/hooks wget https://gist.githubusercontent.com/DiegoSalazar/0f4e81cb80c50128a890675b8d83bf4e/raw/c81f7f3fe2f232eba480c29ab3c3c87018a1d9f9/pre-commit sudo chmod +x pre-commit
Useful when leaving the snippet
binding.pry # debug
in your code during debugging sessions, and other things you don't want to accidentally put in master.