I'm trying to switch my behaivour to use switch
and restore
instead of checkout
, but I'm running into a huge problem when trying to use git switch
to switch branches. My company has a naming convention for our branches, that convention being that branches are named the same as the ticket is. So some of our branches have obscenely long names like feature/ISSUE-123-really-long-title-of-the-issue-which-is-a-pain-to-copy-and-paste-like-this
. With git checkout
I could just type git checkout feature/ISSUE-123
and then hit tab to autocomplete the rest of the branch (even if the branch doesn't exist locally), but for some reason this doesn't work with git switch
, if I type git switch feaure/ISSUE-123
and hit tab nothing happens, even if the branch exists locally.
How do I get git switch
to tab auto complete like git checkout
does?
Details:
OS: Windows 10
Git version: 2.28.windows.1
Shell: PowerShell (running inside Windows Terminal)
I installed git by downloading and executing the Windows 10 64-bit installer available at https://git-scm.com
Best Answer
Git for Windows does not ship with tab completion support for PowerShell. You had an outdated version of Posh-Git installed, a third-party package that provides tab completion for Git in PowerShell.
Much like the original completion support (developed with Git, for Bash, ZSH and tcsh), these need to be updated to support new/changed command line syntax, so make sure to update regularly.