To do so, you need to create .git/hooks/pre-commit file (or append to the existing one):
#!/bin/sh
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
# Redirect output to stderr.
exec 1>&2
for F in $(git status --short -uno --porcelain | egrep -v '^D' | awk '{ printf $2"\n"; }')
do
if grep -iq nocommit "$F"; then
cat <<EOF
Error: '$F' containts "no commit" comment.
You must delete it before it can be committed.
EOF
exit 1
fi
done
And add NOCOMMIT (case insensetive) somewhere in your file that you don't want to commit, i.e.
# NOCOMMIT import pdb a = foo(1, 4) pdb.set_trace()
Hope it'll save some nerves for you.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.