Skip to content

Instantly share code, notes, and snippets.

@sandro
Created February 26, 2015 22:06
Show Gist options
  • Save sandro/68896d6d5273465788a1 to your computer and use it in GitHub Desktop.
Save sandro/68896d6d5273465788a1 to your computer and use it in GitHub Desktop.
#!/bin/sh
# credit to https://gist.github.com/stefansundin/d465f1e331fc5c632088
PUSH_COMMAND=`ps -ocommand= -p $PPID`
while read local_ref local_sha remote_ref remote_sha
do
if [[ "$remote_ref" =~ master && "$PUSH_COMMAND" =~ force|delete|-f ]]; then
echo "Prevented force-push to $remote_ref. This is a very dangerous command."
echo "If you really want to do this, use --no-verify to bypass this pre-push hook."
exit 1
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment