If I type git switch --no-guess <TAB><TAB> I am presented with a list of local branches as possible completions. If I don't pass --no-guess then both local and remote branches are presented.
I created a git alias sb = switch --no-guess, but when I type: git sb <TAB><TAB> I am given both local and remote branches (i.e. it works as a completion as if I did not use --no-guess).
Is there a way to fix this?
The completion script distributed with git does not have this capability built in, so here’s a crude patch to add it. Written against git 2.39.2 and tested only in bash 5.2.15.
This corresponds to the file
contrib/completion/git-completion.bashin the git source distribution (possibly offset). Check with your OS distribution to find out where it installs that file if you want to apply this as a monkey patch; the above can be applied directly it usingpatch -Np0on Debian-based distributions.