Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
git pre-commit hook to block changes containing the string debug in a ruby comment
. git-sh-setup # for die
git-diff-index -p -M --cached HEAD -- | grep '^+' | grep -n '# debug' && die 'Blocking commit: debug detected in code'

This comment has been minimized.

Copy link
Owner Author

@DiegoSalazar DiegoSalazar commented Jun 15, 2016

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
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment