Check out remote git branch with custom name

Sometimes you might want to checkout a multiple copies of a remote branch. In those cases you can not just git checkout the branch you want.

$ git checkout branchName2
error: pathspec 'branchName2' did not match any file(s) known to git.

You will have to checkout the remote branch and specify a branch name using the -b flag.

$ git checkout -b branchName2 origin/branchName

via hallski@StackOverflow