Skip to content

Instantly share code, notes, and snippets.

@SuperSandro2000
Created November 6, 2020 19:01
Show Gist options
  • Save SuperSandro2000/4e5d640865de4a04c2e3ec782f56a473 to your computer and use it in GitHub Desktop.
Save SuperSandro2000/4e5d640865de4a04c2e3ec782f56a473 to your computer and use it in GitHub Desktop.
Git: replace --force with --force-with-lease
git() {
case "$1" in
"push")
shift
local command
command=()
# loop trough all vars or once when no other arguments except push are given
while [[ $# -gt 0 ]]; do
case "$1" in
"-f" | "--force")
command+=("--force-with-lease")
;;
*)
command+=("$1")
;;
esac
shift
done
command git push "${command[@]}"
;;
*)
command git "${@:-"--help"}"
;;
esac
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment