git checkout \'another_branch\'
Or
git checkout origin \'another_branch\'
[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'
]
With Git 2.23 onwards, one can use git switch <branch name>
to switch branches.
If you want the branch to track the remote branch, which is very important if you're going to commit changes to the branch and pull changes etc, you need to add a -t
for the actual checkout like so:
git checkout -t branchname