Skip to content

Instantly share code, notes, and snippets.

@lunfel
Last active October 27, 2020 20:05
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 lunfel/6023547c418a242df11c18b4d0709bf1 to your computer and use it in GitHub Desktop.
Save lunfel/6023547c418a242df11c18b4d0709bf1 to your computer and use it in GitHub Desktop.
Git proxy script to prevent accidentally checking out to another branch
#!/usr/bin/env bash
# This will not block non-interractive shell execution
if [ ! -z "$PS1" ]; then
command git $@
exit 0
fi
case $1 in
checkout)
echo "prevented execution of git checkout"
exit 1
;;
esac
# https://www.cyberciti.biz/faq/ignore-shell-aliases-functions-when-running-command/
command git $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment