Error: pathspec 'temp / versionX' does not match any file known by git

In git, I try to check the versions of a specific repository in the version folder inside the temporary folder, but when I do

git checkout master~XC:/file/path/temp/versionX 

I get an error

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

What causes the problem and how to fix it?

+4
source share
3 answers

git checkout only works inside the "working tree". To do what you want, change the Git view of what the working tree is. There are several ways to do this:

  • option 1: start from the git repository

     cd /path/to/repository # git automatically locates the .git directory as usual git --work-tree=C:/file/path/temp/versionX checkout master~X 
  • option 2: launch from the target directory

     cd C:/file/path/temp/versionX # if --git-dir is specified, Git assumes the working tree is . git --git-dir=/path/to/repository/.git checkout master~X 
  • option 3: start from another directory

     cd /some/arbitrary/path # need to specify both the path to .git and the destination directory git --git-dir=/path/to/repository/.git \ --work-tree=C:/file/path/temp/versionX \ checkout master~X 
+4
source

You cannot place an order. You want git-archive (1). For instance:

 ancestor=10 git archive --prefix="version${ancestor}" master~$ancestor | tar xvf - -C "C:/file/path/temp" 

This will export the named latch to tarball on standard output, which tar will then unzip to the appropriate location. It seems a little bulky at first, but it will grow on you.

0
source

You can try the following:

 mkdir /file/path/temp/versionX cd /file/path/temp/versionX git --git-dir=/path/to/repo/.git --work-path=. checkout master~X 
0
source

All Articles