skip to Main Content

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.

3

Answers


    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

    Login or Signup to reply.
  1. // 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
    
    Login or Signup to reply.
  2. for switching between the branches. If you have already more than one branch.

    git switch <branch-name> //name of the branch where you want to switch 
    

    or,

    git checkout <branch-name>
    

    for creating the branch you can use

    git branch <branch-name> //Name of the branch you want to create
    

    and for creating and switching to that branch simuntaneously.

    git switch -c <branch-name>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search