-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpre-commit
More file actions
23 lines (21 loc) · 866 Bytes
/
pre-commit
File metadata and controls
23 lines (21 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh
# This pre-commit hook will prevent you from committing any line (or filename) containing
# the string NOCOMMIT. Use that tag in comments around source code you want to avoid
# accidentally committing, like temporary IP addresses or debug printfs.
#
# To add it to an existing repository, save it to .git/hooks/pre-commit (or append, if
# that file already exists). Remember to make executable (chmod +x ...)
#
# To automatically add this pre-commit hook to every repository you create or clone:
#
# mkdir -p "$HOME/.git_template/hooks"
# git config --global init.templatedir "$HOME/.git_template"
# cd "$HOME/.git_template/hooks"
# wget https://raw.githubusercontent.com/nobssoftware/nocommit/master/pre-commit
# chmod +x pre-commit
#
if git diff --cached | grep '^[+d].*NOCOMMIT'; then
echo
echo "Adding line containing NOCOMMIT"
exit 1
fi