Igor Gatis
Igor Gatis

Reputation: 4898

How to make git autocomplete branch names for aliases

I have a couple of git alias in my ~/.gitconfig file, like so:

[alias]
  co = checkout
  dd = diff --relative --name-status

While in Bash, when I type git co <tab> I get a list of branches to complete. But when I type git dd <tab> I get a list of files instead. Notice that when I type git diff <tab> I also get a list of branches and tags.

After reading git-complete.bash code, I managed fix that placing the following code in my ~/.bashrc:

_git_dd() { _git_diff ; }

But it does not feel like the right way to fix that.

Upvotes: 1

Views: 35

Answers (0)

Related Questions