Git PathSpec Issue on Git Stash
git, git-stash
Solution
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.)
Problem
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?