Branches let you work on features, fixes, and experiments in isolation without touching the main codebase. VS Code gives you a visual way to create, switch, and merge branches from the Status Bar and Command Palette.
If you are new to Git in VS Code, start with /vscode/how-to-stage-commit-push-and-pull-changes-in-vs-code to learn the commit workflow first.
See your current branch
The current branch name is always visible in the Status Bar, at the bottom-left corner of the window. Select it to open the branch menu, which lists:
- Local branches on your machine
- Remote branches from GitHub or other remotes
- Recently used branches
The Source Control Graph in the Source Control view also shows your branch visually, including how it relates to other branches and the remote.
Create a new branch
Start from the Status Bar
Select the branch name in the Status Bar. In the menu that opens, choose Create new branch.
Name your branch
Type a descriptive name. Use short, clear names like feature/user-auth or fix/login-error. Press Enter.
Pick the source branch
VS Code asks which branch to base your new branch on. Usually this is main or develop. Select it from the list.
VS Code creates the branch and switches to it immediately. The Status Bar updates to show the new branch name. You can also create a branch through the Command Palette: run Git: Create Branch and follow the same prompts.
If you have the GitHub Pull Requests extension installed, you can create a branch directly from a GitHub issue. Right-click the issue and select Start Working on Issue. VS Code creates a branch and prefills the pull request details.
Switch between branches
Select the branch name in the Status Bar and pick any branch from the list. VS Code checks out that branch and updates your files to match its state.
You can also run Git: Checkout to from the Command Palette for the same result. If you have uncommitted changes that conflict with the target branch, Git blocks the switch. Commit or stash your work first.
Merge a branch
When your feature is complete, merge it back into the main branch.
Switch to the target branch
Select the branch name in the Status Bar and switch to the branch you want to merge into (usually main).
Run the merge command
Open the Command Palette and run Git: Merge Branch.
Select the source branch
Pick the feature branch you want to merge from the list.
VS Code merges the branch and shows the result. If the merge succeeds with no conflicts, the changes from the feature branch are now part of the target branch. Push the merged result with Sync Changes.
If there are conflicts, VS Code highlights the conflicting files in the Source Control view under a Merge Changes section. Open any file to resolve conflicts inline or use the 3-way merge editor. Read /vscode/how-to-resolve-git-merge-conflicts-with-the-vs-code-merge-editor for step-by-step guidance.
Publish a branch to GitHub
New branches exist only on your machine until you publish them. In the Source Control view, select the Publish Branch button to push the branch to GitHub and set the upstream. After publishing, the button changes to Sync Changes for normal push and pull.
Rename or delete a branch
To rename the current branch, run Git: Rename Branch from the Command Palette and enter the new name.
To delete a branch, first switch to a different branch (you cannot delete the active one). Then run Git: Delete Branch from the Command Palette and pick the branch to remove. You can also delete the matching remote branch with the Delete Remote Branch action.
Deleting a branch permanently removes it. Make sure the branch has been merged or you no longer need its changes before deleting.
Next, use Git: Merge Branch when you are ready, and learn how to handle conflicts if they come up.
Rune AI
Key Insights
- Select the branch name in the Status Bar to see all branches and switch between them.
- Create a new branch with Git: Create Branch or by selecting the branch indicator and choosing Create new branch.
- Merge a completed branch with Git: Merge Branch from the Command Palette.
- Publish a local branch to GitHub with the Publish Branch button in the Source Control view.
- Delete old branches with Git: Delete Branch after switching away from them.
Frequently Asked Questions
What happens to my uncommitted changes when I switch branches?
How do I delete a branch after merging it?
Can I rename a branch in VS Code?
What is the difference between merge and rebase?
Conclusion
Branches let you work on features and fixes without affecting the main codebase. VS Code makes it easy to create, switch, and merge branches from the Status Bar and Command Palette, so you can focus on writing code instead of remembering Git commands.
More in this topic
How to Use VS Code with WSL 2 on Windows
Run VS Code connected to Windows Subsystem for Linux so you can develop in a full Linux environment with native tools, terminals, and debugging, all from Windows.
20 Best VS Code Extensions for Web Developers in 2026
Twenty carefully chosen VS Code extensions every web developer should know. Covers formatting, linting, frameworks, debugging, Git, and developer experience.
How to Install, Disable, Update, and Uninstall VS Code Extensions
Learn how to install, disable, update, and uninstall VS Code extensions from the Marketplace and the command line. Step-by-step instructions for every action.