Trt Trt Trt Trt - 1 year ago 58
Git Question

Error in git 'error: pathspec'

I am using git to download some files, I did 'git init' then

git pull

The thing is that I want to change the branch I am now at. From 'master' to 'mybranch'.
I am executing
git checkout 'mybranch'
but I am getting this:

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

What is the error?

Answer Source

You aren't setting up any remotes when you initialize an empty repository and issue a git pull.

If you want to use any/all of the remote branches in your repository, you should be using git clone <remote> to create a local clone of the repo, rather than git init; git pull <remote> which simply gives you a copy of the default branch from the remote.

Once you've properly cloned the repository, assuming there is a remote branch origin/mybranch, you can check out a local copy which will track the remote through your command:

git checkout mybranch