I sometimes use the checkout -b
option to create a new branch, check it out at the same time and set up tracking in one command.
In a new environment, I
This simple thing worked for me!
If it says it can't do 2 things at same time, separate them.
git branch branch_name origin/branch_name
git checkout branch_name
First you need to Fetch
the remote (the specific branch), then you can create a local br and track it with that remote branch using your command (i.e. checkout
with -b and --track).
For me I needed to add the remote:
git remote -add myRemoteName('origin' in your case) remoteGitURL
then I could fetch
git fetch myRemoteName
If you got white space in your branch then you will get this error.
FWIW: If you have a typo in your branchname you'll get this same error.
It causes by that your local branch doesn't track remote branch. As ssasi said,you need use these commands:
git remote update
git fetch
git checkout -b branch_nameA origin/branch_nameB
I solved my problem just now....