I just made git better

drop this in ~/bin/git:

#!/bin/sh

if [ "$1" = "push" ]; then
    for arg in "$@"; do
        shift
        case "$arg" in
            "-f"|"--force")
                arg="--force-with-lease"
                ;;
            "--really-force")
                arg="--force"
                ;;
        esac
        set -- "$@" "$arg"
    done
fi

exec /usr/bin/git "$@"
4 Likes

Looks like a good answer to this question:

https://stackoverflow.com/questions/30542491/push-force-with-lease-by-default

:slight_smile:

I’ve improved it further, significantly:

#!/bin/sh

if [ "$1" = "push" ]; then
    for arg in "$@"; do
        shift
        case "$arg" in
            "-f"|"--force"|"--force-with-lease"|"--really-force")
                echo 'OF COURSE NOT!' >&2
                exit 1
                ;;
        esac
        set -- "$@" "$arg"
    done
fi

exec /usr/bin/git "$@"