Skip to content

Instantly share code, notes, and snippets.

@reececomo
Last active November 8, 2024 01:32
Show Gist options
  • Select an option

  • Save reececomo/f2c299cae91c96dacd8d62ff44fa47a2 to your computer and use it in GitHub Desktop.

Select an option

Save reececomo/f2c299cae91c96dacd8d62ff44fa47a2 to your computer and use it in GitHub Desktop.
protect git push -f
git() {
WARN='\033[0;33m'
RESET='\033[0m'
if [[ "$1" == "push" && "$2" == "-f" ]]; then # idiot safety net
echo -e "${WARN}note: running with --force-with-lease. run with \"--force\" to override.${RESET}"
command git push --force-with-lease "${@:3}"
else
command git "$@"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment