3

I define a number of aliases for my git work flow.

alias gs='git status'
alias ga='git add -u'
alias gaa='git add -A'
alias gc='git commit'
alias gr='git checkout --'
alias gu='git reset HEAD'
alias gch='git checkout'
alias gst='git stash save'
alias gmm='git fetch && git merge origin/master'
alias glf="git log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
alias gl='glf | head'

The problem with this is that using the aliases disables bash's git tab completion.

For example, with the following:

$ gs
On branch master
Your branch is up-to-date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   bar
    modified:   foo

no changes added to commit (use "git add" and/or "git commit -a")

If I type git add and then hit tab, it will display only the modified files:

$ git add 
bar  foo     

If I type b and tab, it will complete bar

However, if I try use my alias, tab completion no longer works.

$ ga 
bar  baz  foo  etc..  etc..  etc..

Is it possible to enable git tab completion with my aliases?

0 Answers0