关于Git Stash的Git PathSpec问题 [英] Git PathSpec Issue on Git Stash
问题描述
当我将新命令 stash -p - {pathspec}
的新版本 2.13.0.windows.1 运行为
git stash -p - AB.Dir1 / Dir2 / DestinationHierarchyCreator.cs
报告错误
错误:pathspec'AB.Dir1 / Dir2 / DestinationHierarchyCreator.cs'不匹配任何已知的git文件。
然而当我做一个 git status
,其中我从实际上复制了文件,它会报告
您的分支最新-date与'origin / project / develop'。
没有为commit提交更改:
(使用git add< file> ...更新将提交的内容)
(使用git checkout - < file> ;. ..放弃工作目录中的更改)
修改:AB.Dir1 / Dir2 / DestinationHierarchyCreator.cs
如果我转到文件所在的目录并执行 git stash -p - DestinationHierarchyCreator.cs
它会失败,并显示相同的错误。 / p>
如果我运行命令 git stash -p - * .cs
,我可以将碎片保存到存储中。
所以我理解 git stash -p
选项错误,或者是我处理的pathspec不正确的单个文件或其他东西?
刚刚碰到相同的问题。看起来, git stash
pathspecs必须相对于存储库根目录(顶部) - 而不是您当前的工作目录。
$ b $
因此,如果您当前的工作目录是〜/ dev / git_project_root / subdir,那么您需要使用:
git stash -p - subdir / AB.Dir1 / Dir2 / DestinationHierarchyCreator.cs
(通配符 git stash -p - * .cs
可以工作,因为它匹配了根目录下的所有修改的* .cs文件 - 可能你只有那个。)
When I run the new version 2.13.0.windows.1 of its new command stash -p -- {pathspec}
as
git stash -p -- AB.Dir1/Dir2/DestinationHierarchyCreator.cs
it reports the error
error: pathspec 'AB.Dir1/Dir2/DestinationHierarchyCreator.cs' did not match any file(s) known to git.
Yet when I do a git status
, where I copied the file from actually, it reports
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
If I go to the directory the files lives in and do git stash -p -- DestinationHierarchyCreator.cs
It fails with the same error.
If I run the command git stash -p -- *.cs
then I can save fragments to the stash.
So is my understanding of the git stash -p
option wrong, or is my handling of the pathspec incorrect for individual file(s) or something else?
Just ran into the same problem. It appears that git stash
pathspecs must be relative to the repository root (top) -- not to your current working dir.
Since git status
("unlike many other Git commands") shows paths "relative to the current directory if you are working in a subdirectory," this seems prone to confusion.
So if your current working directory is, say, ~/dev/git_project_root/subdir, you'd need to use:
git stash -p -- subdir/AB.Dir1/Dir2/DestinationHierarchyCreator.cs
(The wildcard git stash -p -- *.cs
worked because it was matching all modified *.cs files below your root -- and probably you only had that one.)
这篇关于关于Git Stash的Git PathSpec问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!