user11
user11

Reputation: 331

Not able to checkout code from git

I am trying to fetch source code from a repository but when I run command to fetch the source code I get an error which says "error pathspec did not match any files known to git".

Following is the sequence of command that i run to fetch source code.

$ git remote add origin git@....
$ git fetch
$ git checkout test

Upvotes: 2

Views: 669

Answers (1)

janos
janos

Reputation: 124704

Git tries to resolve git checkout test like this:

  • If there is a local branch named "test", then checkout that
  • If there is a remote branch named "test", for example origin/test, then create a local branch from it and checkout (equivalent to git checkout -b test origin/test
  • If there is a file or directory named "test", then checkout that, which will undo uncommitted (but unstaged) changes to that file/directory

If none of the above match, then Git gives the error:

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

I'm not sure what you were trying to do here. If you wanted to checkout the "test" branch, it seems it doesn't exist. Check what branches you have with git branch -a. If you wanted to checkout a file/dir, it doesn't exist. Check what files you have with git ls-files.

Upvotes: 2

Related Questions