当我运行新版本时2.13.0.windows.1其新命令stash -p -- {pathspec}
as
git stash -p -- AB.Dir1/Dir2/DestinationHierarchyCreator.cs
它报告错误
错误:路径规范“AB.Dir1/Dir2/DestinationHierarchyCreator.cs”与 git 已知的任何文件都不匹配。
然而当我做一个git status
, 我实际上从哪里复制了文件,它报告
Your branch is up-to-date with 'origin/project/develop'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: AB.Dir1/Dir2/DestinationHierarchyCreator.cs
如果我转到文件所在的目录并执行git stash -p -- DestinationHierarchyCreator.cs
它因相同的错误而失败。
如果我运行命令git stash -p -- *.cs
然后我可以将碎片保存到储藏室中。
我的理解也是如此git stash -p
选项错误,或者我对单个文件或其他文件的路径规范的处理不正确?
刚刚遇到了同样的问题。看起来git stash
路径规范必须相对于存储库根目录(顶部)——而不是相对于您当前的工作目录。
Since git status
(“与许多其他 Git 命令不同”)显示路径“相对于当前目录 https://git-scm.com/docs/git-status#_output如果您在子目录中工作,”这似乎很容易造成混乱。
因此,如果您当前的工作目录是 ~/dev/git_project_root/subdir,您需要使用:
git stash -p -- subdir/AB.Dir1/Dir2/DestinationHierarchyCreator.cs
(通配符git stash -p -- *.cs
之所以有效,是因为它匹配根目录下所有修改过的 *.cs 文件——而且可能你只有那个文件。)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)