Skip to content

Instantly share code, notes, and snippets.

@mgershovitz
Forked from hraban/pre-commit.md
Last active September 8, 2022 07:37
Show Gist options
  • Save mgershovitz/ea9ab197b8129d4c8c0aee15c2658bc4 to your computer and use it in GitHub Desktop.
Save mgershovitz/ea9ab197b8129d4c8c0aee15c2658bc4 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