Version 1.107 is now available! Read about the new features and fixes from November.
Dismiss this update
Git branches enable you to work on different features or experiments simultaneously without affecting your main codebase. VS Code provides tools for branch management, Git worktrees for parallel development, and stash management for temporary changes.
This article covers working with branches, worktrees, and stashes in VS Code to manage parallel development work.
Branches are lightweight, movable pointers to specific commits in your Git history. They allow you to diverge from the main line of development and work on features independently.
For example, suppose you're working on a web application and need to add user authentication while also fixing a bug in the payment system. You can create two branches:
feature/user-authentication - contains your login and signup functionalitybugfix/payment-validation - contains fixes for payment processing errorsEach branch maintains its own set of changes without affecting the other. You can switch between branches to work on different tasks, and later merge the completed branches back into your main branch.
The current branch appears in several places in VS Code:

Switching to a different branch is called "checking out" a branch in Git terminology. When you check out a branch, Git updates your working directory to match that branch's state.
To switch to a different branch:
Select the branch name in the Status Bar, or run the Git: Checkout to command from the Command Palette (⇧⌘P (Windows, Linux Ctrl+Shift+P)).
Choose from the list of available branches:
If you have uncommitted changes when switching branches, Git might prevent the switch to avoid losing work. Consider committing your changes or using a stash before switching.
Create a new branch to start working on a feature or experiment:
Select the branch name in the Status Bar or run Git: Create Branch from the Command Palette.
Enter a name for your new branch. Use descriptive names like feature/user-authentication or bugfix/login-error.
VS Code can generate random branch names for you. Configure this with the git.branchRandomName.enable and git.branchRandomName.dictionary settings.
Choose the source branch (usually main or develop) from which to create the new branch.

VS Code switches to the new branch after creation.
If you use the GitHub Pull Requests and Issues extension, you can create branches directly from GitHub issues, which gets you started working in a new local branch and automatically prefills the pull request for you.
To rename the current branch:
To delete a branch:
You can also delete a remote branch by using the matching Delete Remote Branch action.
Deleting a branch permanently removes it from your local repository. Make sure the branch has been merged or you no longer need the changes.
When your feature is complete, merge it back into the main branch:
main or develop).To publish a branch to your remote repository, use the Publish Branch action.
VS Code shows the merge result in the Source Control view. If there are conflicts, VS Code highlights them and provides tools to resolve them. Learn more about resolving merge conflicts.
VS Code has built-in support for Git worktrees, making it easy to manage and work with multiple branches at the same time.
A worktree is a separate checkout of a Git branch in its own directory. This allows you to have multiple working directories for the same repository, each on a different branch. Worktree functionality is especially useful for:
To create a new worktree in VS Code:
Open the Source Control Repositories view from the Source Control view.

Select your repository, open the More Actions (...) menu, and choose Worktrees > Create Worktree.

Follow the prompts to choose a branch and location for the new worktree.
VS Code creates a new folder for the worktree at the specified location and checks out the selected branch into that folder.
The new worktree appears as a separate entry in the Source Control Repositories view.
VS Code can display multiple repositories (including worktrees) simultaneously:
There are multiple ways to open a worktree:
Directly open the folder associated with the worktree in VS Code. VS Code automatically detects that it's a worktree of an existing repository.
Right-click the worktree in the Source Control Repositories view and select Open Worktree in New Window or Open Worktree in Current Window.
Run the Git: Open Worktree in Current Window or Git: Open Worktree in New Window command in the Command Palette and select the desired worktree.
When you make changes in a worktree, you can compare those changes with your main workspace and bring worktree changes back into your main repository.
In the Source Control view, right-click a changed file in the worktree and select Compare with Workspace to see the differences side-by-side.

After reviewing, use the Migrate Worktree Changes command from the Command Palette to merge all changes from a worktree into your current workspace.