Define git alias with the same name to shadow original command

As a workaround, you can define aliases in Bash to get the result you want. Here’s something I just knocked up for a pet peeve of mine – that ‘git add’ is not verbose by default. (And there’s no config setting for it).

Put this in your ~/.bash_profile or ~/.bash_rc

function do_git {
  cmd=$1
  shift
  extra=""
  if [ "$cmd" == "add" ]; then
    extra="-v"
  elif [ "$cmd" == "rm" ]; then
    extra="--cached"
  fi
  git="$(which git)"
  ex="$git $cmd $extra $@"
  ${ex}
}
alias  git="do_git"

Then just call it like normal:

$ git add .
add 'foo'

Leave a Comment