Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从本地git存储库签出单个文件?_Git_Git Checkout - Fatal编程技术网

如何从本地git存储库签出单个文件?

如何从本地git存储库签出单个文件?,git,git-checkout,Git,Git Checkout,我有一个本地git存储库,我需要执行TFS“撤消挂起的更改”的等效操作。没有远程存储库。没有树枝,只有主人。我尝试了“问题”和“问题”中的几乎所有建议。当我执行“$git checkout HEAD--error.cshtml”时,我总是会得到“error:pathspec'error.cshtml'与git已知的任何文件都不匹配”。如何从存储库中获取单个文件的最新提交版本?您确定该文件确实在存储库中吗?git log--oneline--error.cshtml是否产生任何输出?还要检查您正在

我有一个本地git存储库,我需要执行TFS“撤消挂起的更改”的等效操作。没有远程存储库。没有树枝,只有主人。我尝试了“问题”和“问题”中的几乎所有建议。当我执行“$git checkout HEAD--error.cshtml”时,我总是会得到“error:pathspec'error.cshtml'与git已知的任何文件都不匹配”。如何从存储库中获取单个文件的最新提交版本?

您确定该文件确实在存储库中吗?
git log--oneline--error.cshtml
是否产生任何输出?还要检查您正在执行命令的目录是否是repo根目录中的文件?文件是否在子目录中?如果是后者,则需要使用执行命令的dir中的完整路径:
git checkout HEAD--path/to/error.cshtml
。就是它@Waylan,该文件向下数个子目录。我原以为通过回购协议可以再次结账。非常感谢。