For an alias to git itself, eg. alias g=git, you'll find your answer more easily here.
For git subcommand aliases, eg. alias gco = "git checkout", look here.
I type git far too often, so I've aliased it:
alias g='git'
However, now I can't do:
g comtab
and have the completion present me with:
g commit
How do I get completion running again?
Duplicate differentiation
This equal-first meta answer suggests keeping the specific case with a with a link to the more generic question. I've added the link to the more generic case in this edit.
The asserted duplicate question is more generic - but mostly about aliases to git subcommands, rather than an alias to git itself.
This question is about the specific case where the alias is to git itself.
In the marked duplicate, the git-itself case is only answered in the 4th shown answer, and in a comment to the first listed answer. Reading another comment is required for the second piece of the puzzle (source /usr/share/bash-completion/completions/git) to get it working via that method.
Addressing the links in the comments below:
- @ewcz's link is the marked duplicate and has already been addressed
- Remy J's links
- This is question as asked (and answered) is also about
gitsubcommands - This is an even more generic question about non-
gitaliases, which doesn't isn't near to the best solution in this case - This is the same as @ewcz's link (already addressed)
- This is question as asked (and answered) is also about