I think this may be a duplicate, but I can't find a straight answer to my current problem.
I'm trying to get my macosx git autocomplete to work similar to the git autocomplete I have on my linux box at work. I found some instructions that led me to install https://github.com/git/git/tree/master/contrib/completion (i'm using the .bash version). Everything works great, the only catch is that now the autocomplete shows branches that are already deleted.
Does anyone have an alternate script/method, or even just instruction on how to edit the current script to avoid showing all of my branches, and just the current local branches that are available.
thank you, Brodie
[edit]
I figured an example was in order, to help make the question clearer.
#result of git branch is as expected
$ git branch
*master
somefeature
someotherfeature
#now I delete one of my feature branches
$ git branch -D someotherfeature
$ git branch
*master
somefeature
#the branch someotherfeature is gone, as expected
#however when I attempt an autocomplete, like with git checkout, I get everything remote branches, local branches, and previously deeted branches.
$ git checkout <tab><tab>
master somefeature someotherfeature remote/origin/master remote/origin/remotebranch
I'd like to have it just show my local branches like it does on my linux box
# i.e. given 2 local branches `master` and `somefeature` autocomplete would work as follows
$ git checkout <tab><tab>
master somefeature
In my version of git-completion.bash
I can do the following to prevent these deleted branches displaying as part of completion:
export GIT_COMPLETION_CHECKOUT_NO_GUESS=1
I found it mentioned in the file (homebrew - /usr/local/Cellar/git/2.19.2/share/zsh/site-functions/git-completion.bash
) and also in the SO post Disable auto-completion of remote branches in Git Bash?.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With