Ricky Robinson Ricky Robinson - 4 months ago 25
Git Question

Git: can't switch to new remote branch

I have an account on

and I use it from two different machines. On one, I created a new branch
and switched to it. Then I did my modifications to my code, I committed and pushed to

On the second machine, I can't figure out how to push to it.

$ git pull origin myNewBranch
From https://github.com/myUsername/myProject
* branch myNewBranch -> FETCH_HEAD
Already up-to-date.

[ I had already successfully pulled from it]

Then I try to switch to it, but I get an error:

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

What am I missing?


You need to fetch the data onto your local repository on machine 2 first:

$ git fetch origin
$ git checkout origin/myNewBranch