Skip to content

Instantly share code, notes, and snippets.

@JellyWX
Forked from mgershovitz/pre-commit
Created September 8, 2022 07:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JellyWX/f6adc12613646a42f0387b3ef2fc5a88 to your computer and use it in GitHub Desktop.
Save JellyWX/f6adc12613646a42f0387b3ef2fc5a88 to your computer and use it in GitHub Desktop.
Git pre-commit hook to prevent accidentally committing debug code (add NO_COMMIT in source comment)
#!/bin/bash
if git diff --cached | grep '^[+d].*NO_COMMIT'; then
echo "Can't commit file with NO_COMMIT comment, remove the debug code and try again"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment