Git: cannot checkout branch – error: pathspec ‘…’ did not match any file(s) known to git

Try git fetch so that your local repository gets all the new info from Github. It just takes the information about new branches and no actual code. After that, the git checkout should work fine.

You basically see the branch, but you don’t have a local copy yet!…

You can simply fetch and then checkout to the branch, use the command below to do that:

git fetch
git checkout <Branch name here>

I also created the image below for you to share the differences, look at how fetch works, and also how it’s different to pull:

enter image description here

Leave a Comment