隐藏的文件在“git 状态”中显示为未更改(git v.2.16.0)

Stashed files show up as unchanged in `git status` (git v.2.16.0)

我使用 git-for-windows v2.16.0 并遇到了以下问题,该问题也被报告 here:

我最初的工作状态是干净的; 'git status' 的输出:

git status
On branch beta
nothing to commit, working tree clean

然后我进行本地更改。 git status 的输出:

git status
On branch beta
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:   app/src/main/java/android_serialport_api/sample/Debug.java

no changes added to commit (use "git add" and/or "git commit -a")

然后我把它们藏起来 'git stash':

git stash
Saved working directory and index state WIP on beta: 2fca403 working on the console

现在我的工作目录应该是干净的,但是 git status 的输出仍然是:

git status
On branch beta
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:   app/src/main/java/android_serialport_api/sample/Debug.java

no changes added to commit (use "git add" and/or "git commit -a")

导致无法git checkout

这是 Git 中针对 Windows 的 known bug,它已在 v2.16.0(3) 中修复。更新到较新的版本将修复此错误。

感谢@choroba 指出报告的问题!

最近,隐藏的文件数量可能仍未显示,git status 使用 porcelain v2 ()

git status --porcelain=v2 --show-stash 

使用 Git 2.34(2021 年第 4 季度),它现在允许“git status --porcelain=v2"(man)像正常输出一样显示带有 --show-stash 的存储条目数.

参见 commit 2e59e78, commit 612942a (22 Oct 2021) by Øystein Walle (Osse)
(由 Junio C Hamano -- gitster -- in commit dea96aa 合并,2021 年 11 月 29 日)

status: print stash info with --porcelain=v2 --show-stash

Signed-off-by: Øystein Walle

The v2 porcelain format is very convenient for obtaining a lot of information about the current state of the repo, but does not contain any info about the stash.
'git status'(man) already accepts --show-stash but its silently ignored when --porcelain=v2 is given.

Let's add a simple line to print the number of stash entries but in a format similar in style to the rest of the format.

git status 现在包含在其 man page 中:

Stash Information

If --show-stash is given, one line is printed showing the number of stash entries if non-zero:

stash