Skip to content

Instantly share code, notes, and snippets.

@skyebook
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skyebook/5bdcaab9546b3432fcb5 to your computer and use it in GitHub Desktop.
Save skyebook/5bdcaab9546b3432fcb5 to your computer and use it in GitHub Desktop.
push-defense
#!/bin/bash
gitResult=$(git --version | grep 'git version 2.')
if [ -n "$gitResult" ]; then
# Don't push to any remotes unless a remote branch is specified
git config --global push.default nothing
mkdir -p ~/bin/git-hooks/hooks
curl https://raw.githubusercontent.com/bigbinary/tiny_scripts/master/git-hooks/hooks/pre-push > ~/bin/git-hooks/hooks/pre-push
chmod a+x ~/bin/git-hooks/hooks/pre-push
git config --global init.templatedir "${HOME}/bin/git-hooks"
else
# Need to update to git 2.x
echo "This tool requires at least git 2 to run. Your git version is $(git --version)"
fi
@timonus
Copy link

timonus commented Dec 3, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment