VS Code creates a local copy of a remote branch every time I switch to it

VS Code keeps creating local copy of a remote branch at every time I checkout from the remote branch but I don't want this, because it creates a mess in the panel with same named branches all over the panel. I don't want this and only want to track the changes remotely. How can I do this?


  • Use the Git: Checkout to (Detached) command in the command palette instead of Git: Checkout to or the quick pick menu that appears when you click the head indicator in the status bar. If you want to bind a keyboard shortcut to that command, its ID is git.checkoutDetached.

    If you're interested in the history of how this feature came to be, this was raised as a feature request before for there to be a way to checkout without creating a local tracking branch: Option to disable creation of a branch when a remote tracking branch is selected #96264. The feature was released in the November 2020 (1.52) release of VS Code.

    Though note that (according to this comment,) the status bar indicator of the current HEAD will show the commit hash instead of the remote branch name.

    For your reference / learning purposes, I found that issue ticket by googling "github vscode issues checkout remote branch without creating local tracking branch".