0
Q:

how to switch branches in git

git switch <branch_name>

git checkout <branch_name> 
14
[git checkout "branch_name"]

is another way to say:

[git checkout -b branch_name origin/branch_name]

in case "branch_name" exists only remotely.

[git checkout -b branch_name origin/branch_name] is useful in case you have multiple remotes.

Regarding [git checkout origin 'another_branch'] I'm not sure this is possible, AFAK you can do this using "fetch" command -- [git fetch origin 'another_branch']
9
$ git checkout <existing_branch>

$ git checkout -b <new_branch>
12
git switch branch_name

git checkout branch_name 
3
$ git checkout -b myfeature dev
2
git checkout [branch name]
1
$ git checkout feature
2
wonder.woman@highfive project %  git checkout branch_name 
#this let you keep edited files
wonder.woman@highfive project %  git switch branch_name  
1
$ git branch iss53
$ git checkout iss53
0
Github branch 
pull request in branch
1

New to Communities?

Join the community