How to Create a Git Branch in VS Code

Visual Studio Code provides a robust, built-in graphical interface that makes version control management seamless. This article explains how to quickly create a new Git branch directly within the VS Code interface using three different methods, as well as how to publish your new branch to a remote repository.

Method 1: Using the Status Bar

The quickest way to create a new Git branch is by using the VS Code status bar located at the bottom of the window.

  1. Look at the bottom-left corner of the VS Code interface to find the current Git branch name (e.g., main or master).
  2. Click on the branch name.
  3. A dropdown menu will appear at the top of the screen. Select + Create new branch… (or + Create new branch from… if you want to branch from a specific commit or tag).
  4. Type the name of your new branch and press Enter.

VS Code will automatically create the branch and switch your workspace to it.

Method 2: Using the Command Palette

If you prefer keyboard shortcuts, you can use the Command Palette to create a branch.

  1. Open the Command Palette by pressing Ctrl + Shift + P (Windows/Linux) or Cmd + Shift + P (macOS).
  2. Type Git: Create Branch into the search bar and select the command from the list.
  3. Type your desired branch name and press Enter.
  4. If prompted, choose the reference branch you wish to branch off from.

Method 3: Using the Source Control Panel

You can also manage your branches through the dedicated Source Control side menu.

  1. Click on the Source Control icon in the Activity Bar on the left side of the screen (or press Ctrl + Shift + G).
  2. Click on the three horizontal dots () at the top of the Source Control panel to open the “Views and More Actions” menu.
  3. Hover over Branch and click Create Branch… from the submenu.
  4. Enter your new branch name and press Enter.

Publishing the New Branch to a Remote Repository

Once you create a branch locally, it does not automatically exist on your remote repository (such as GitHub, GitLab, or Bitbucket). To upload it:

  1. Look at the status bar at the bottom left. A cloud icon with an arrow or a Publish Branch button will appear next to your new branch name.
  2. Click Publish Branch.

Alternatively, you can open the Source Control panel and click the blue Publish Branch button. Your local branch is now synced with your remote repository.