错误:pathspec';临时/版本X';与git已知的任何文件都不匹配
在git中,我试图将特定存储库的版本签出到临时文件夹中的版本文件夹中,但当我签出时错误:pathspec';临时/版本X';与git已知的任何文件都不匹配,git,git-checkout,filepath,Git,Git Checkout,Filepath,在git中,我试图将特定存储库的版本签出到临时文件夹中的版本文件夹中,但当我签出时 git checkout master~X C:/file/path/temp/versionX 我得到了错误 error: pathspec 'temp/versionX' did not match any file(s) known to git. 问题的原因是什么?如何解决?签出不能这样使用。您需要的是git归档(1)。例如: ancestor=10 git archive --prefix="ver
git checkout master~X C:/file/path/temp/versionX
我得到了错误
error: pathspec 'temp/versionX' did not match any file(s) known to git.
问题的原因是什么?如何解决?签出不能这样使用。您需要的是git归档(1)。例如:
ancestor=10
git archive --prefix="version${ancestor}" master~$ancestor |
tar xvf - -C "C:/file/path/temp"
这将把命名的commit导出到标准输出上的tarball,tar随后将在适当的位置解包。一开始它看起来有点麻烦,但它会在你身上成长。
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
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
- 选项3:从其他目录运行
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
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
mkdir /file/path/temp/versionX
cd /file/path/temp/versionX
git --git-dir=/path/to/repo/.git --work-path=. checkout master~X
我希望避免归档,因为我需要的所有东西都要花很长时间才能打开。我目前正在做的这个工作项目是解包几百个版本的回购协议,在未来的版本中是几千个。我希望将repo的版本签出到git repo中的另一个文件中,然后使用move命令将其移出,希望速度更快。我将其移动到的文件位于我正在工作的目录中。比如说,我在文件C:/dir/myRepo中工作。我试图将文件签出到的文件是C:/dir/myRepo/oldversion/temp/versionX。我是否按照您刚才指示的方式签出文件?@SSEMember:我更新了我的答案。这回答了你的问题吗?我假设
master~X
是包含你想要的文件的旧版本,而C:/file/path/temp/versionX
是你想要放置旧文件的地方。缺少两个信息:您想要哪个旧文件(相对于Git存储库的根)?Git存储库的路径是什么?repo的路径是C:/file/path