This is why you get an error message.
git checkout can do one of two things. If you simply specified a branch and did not specify any paths, it will switch your current branch to the specified branch.
git checkout mybranch
If you specify several paths, then git will check these paths either from the index, or, if you specify a branch, from this branch.
git checkout myfile
As you can see, there is a potential ambiguity. What happens if you have a branch named myfile or a file named mybranch ?
The way git removes this ambiguity is that it checks the parameter to see if it matches the branch, and if not, it is assumed that the parameter refers to the file. If you have a branch and a file with the same name, you can force git to treat the parameter as a file with this syntax.
git checkout -- myfile
The -b option, which creates a new branch, is only valid when using the checkout branch switch form, and not when you check the specified files from the index.
git checkout -b newbranch myfile
If you try git checkout -b newbranch origin/BRANCH and you get this error, it means that origin/BRANCH does not match the name of any branch you have, so git suggested that you should reference the file.
To show what remote branch links you can do, git branch -r . If you don't have a link to a branch that you think should exist, you might need to do git fetch to extract it from the remote.
If you supply -b but donβt have any branch name to establish a new branch, git uses HEAD by default, that is, the commit on which your current branch is enabled.
git checkout -b origin/BRANCH
This creates a new local branch named origin/BRANCH based on your current commit. This, at best, can cause you some confusion and does not look like what you want at all.