Keeping Pry Breakpoints out of Git

My Ruby workflow as of late has almost always contained Git for version control, and Pry for debugging.

Although it’s extremely convenient during development to add a quick breakpoint using binding.pry, it can be a bit frustrating to clients if you accidentally deploy with these breakpoints still intact.

After hunting around for a bit, I decided to write a pre-commit hook that would check the files I was about to check in to ensure that I didn’t accidentally still have breakpoints enabled.

This file just needs to be saved to /path/to/source/.git/hooks/pre-commit and made executable.

curl $HOOK_URL > /path/to/source/.git/hooks/pre-commit
chmod +x /path/to/source/.git/hooks/pre-commit

If you happen to leave a breakpoint intact, the next time you try to commit your changes, the commit will fail and indicate where these breakpoints are, and what files need to be updated to allow the commit to succeed.