我刚刚在 Windows 上尝试过:它适用于没有“.”的普通文件夹
C:\Users\vonc\data\git\git>git st
On branch master
Your branch is up-to-date with 'origin/master'.
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: Documentation/blame-options.txt
C:\Users\vonc\data\git\git>git stash -- Documentation\blame-options.txt
Saved working directory and index state WIP on master: b14f27f91 Tenth batch for 2.13
即使在 bash 会话中,并且使用 -p,它仍然可以工作
vonc@bvonc MINGW64 ~/data/git/git (master)
$ git stash -p -- Documentation/blame-options.txt
diff --git a/Documentation/blame-options.txt b/Documentation/blame-options.txt
index dc41957af..96a5b1b4a 100644
--- a/Documentation/blame-options.txt
+++ b/Documentation/blame-options.txt
@@ -1,7 +1,7 @@
-b::
Show blank SHA-1 for boundary commits. This can also
be controlled via the `blame.blankboundary` config option.
-
+sss
--root::
Do not treat root commits as boundaries. This can also be
controlled via the `blame.showRoot` config option.
Stash this hunk [y,n,q,a,d,/,e,?]? y
Saved working directory and index state WIP on master: b14f27f91 Tenth batch for 2.13
在带有“.”的文件夹上:
vonc@bvonc MINGW64 ~/data/git/git (master)
$ git stash -p -- a.b/c
error: pathspec 'a.b/c' did not match any file(s) known to git.
Did you forget to 'git add'?
所以这可能是一个问题。
注意,在 Git 2.29(2020 年第四季度)中,不再有“Show blank SHA-1 for boundary commits”:一些面向最终用户的消息已更新为与哈希算法无关。
参见Junio C Hamano (gitster)commit 4279000(2020 年 8 月 13 日)。
(由 Junio C Hamano -- gitster -- 合并于 commit 2a978f8,2020 年 8 月 19 日)
messages:在面向最终用户的消息中避免使用 SHA-1
当我们指的是面向最终用户的消息中的(十六进制)对象名称时,仍有少数提到 SHA-1。
重写它们。
我希望这主要是 s/SHA-1/object name/,但有些消息需要重新措辞以保持结果可读。
那么新的错误信息将是:
Do not show object names of boundary commits