在 git 中,我试图将特定存储库的版本 check out 到临时文件夹内的版本文件夹中,但是当我这样做时
git checkout master~X C:/file/path/temp/versionX
我得到了错误
error: pathspec 'temp/versionX' did not match any file(s) known to git.
是什么导致了问题,我该如何解决?
最佳答案
git checkout
仅在“工作树”内运行。要做你想做的事,改变 Git 对工作树的看法。有几种不同的方法可以做到这一点:
选项 1:从 Git 存储库运行
cd /path/to/repository # git automatically locates the .git directory as usual git --work-tree=C:/file/path/temp/versionX checkout master~X
选项 2:从目标目录运行
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
选项 3:从其他目录运行
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
关于git - 错误 : pathspec 'temp/versionX' did not match any file(s) known to git,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11247432/