Checking out a git branch when multiple remotes (repos) are involved

When you are dealing with a local git repository which has multiple remotes defined (i.e. has multiple remote repositories possibly carrying the same branches, such as multiple forks), then the right way to checkout a working branch from one of them is to use the below syntax:

git checkout -b master origin/master

Where origin is the name of the remote.

You can also delete a local branch before switching to another repository’s copy of it:

git checkout origin/master
git branch -D master
git checkout -b master origin/master