Skip to content

Instantly share code, notes, and snippets.

@mgershovitz
mgershovitz / pre-commit
Last active September 8, 2022 07:37 — forked from hraban/pre-commit.md
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