11

When I want to check a branch to checkout to and I don't remember the exact name, I can't use Tab-completion, as the pool it uses is the branch pool of remote.

How can I make the Tab only look at the git branch pool (i.e. only choose from the local branches I created / already checkedout)

CIsForCookies
  • 12,097
  • 11
  • 59
  • 124
  • 4
    Possible duplicate of [Disable auto-completion of remote branches in Git Bash?](https://stackoverflow.com/questions/6623649/disable-auto-completion-of-remote-branches-in-git-bash) – phd Jan 28 '19 at 16:22
  • https://stackoverflow.com/search?q=%5Bgit%5D+tab+completion+local+branches – phd Jan 28 '19 at 16:23
  • 1
    https://cmetcalfe.ca/blog/git-checkout-autocomplete-local-branches-only.html – Vinz Jan 28 '19 at 16:25

2 Answers2

1

One way is to modify the standard code completion script for git checkout, example (& credit) below:

https://gist.github.com/mmrko/b3ec6da9bea172cdb6bd83bdf95ee817

be_es
  • 41
  • 1
-3

If i understand your problem you can first run

git branch

if the branch is locally. Else you can

git branch --all

if the branch is on repository and you didn't checkout it yet. Then you can

git checkout <branchName>
  • 2
    You are just *showing* the available branches, not affecting how tab completion for Git works. – chepner Aug 07 '21 at 13:29