If you try to commit directly to a "forbidden" branch like master or staging, you'll get a warning like this:
HOLD UP!
You are trying to commit directly to *master* branch.
(>_<)
You can force the commit by adding --no-verify to the command.
Trying to commit debuggers, logs, and merge conflict markers will also trigger the warning and tell you where the issue is.
cd
into the root of the respository you want to add the pre-commit hook to and run:
curl https://gist.githubusercontent.com/patmood/9609325/raw/9f4bd39dba7d5a58b431277b6989e3232296c6ae/pre-commit > .git/hooks/pre-commit && chmod u+x .git/hooks/pre-commit