Home > Back-end >  How to switch git branches in vscode?
How to switch git branches in vscode?

Time:12-01

I have GitHub repository with multiple branches, and I want to commit and push changes to a specific branch, how can I switch from "master*" branch to another branch?

I tried to switch by clicking the branch name in the left bottom side of the screen and it didn't switch.

CodePudding user response:

  1. Access the "Source Control" tab on the left side of VSCode
  2. Click on the "three small dots" next to the refresh button
  3. Click on the "Checkout to..." option
  4. Choose the branch you want to switch to

You can also try this: you do git branch branch_name then git checkout branch_name

CodePudding user response:

// it will create new branch and switch to that branch
git checkout -b branch-name

// it will directly switch to previously created branch
git checkout branch-name
  • Related