12

I use git-for-windows v2.16.0 and encountered the following problem, which also was reported here:

I initially have a clean working state; Output of 'git status':

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

Then I make local changes. Output of 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")

Then I stash them with 'git stash':

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

Now my working directory should be clean but the output of git status still reads:

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")

Which leads to not being able to git checkout etc.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Mode77
  • 991
  • 8
  • 28
  • 4
    What version of git are you using? I upgraded to v2.16.0 a week or so ago, and since then I've noticed the same behavior. `git stash` did stash the changes, and the file is reverted (doing a diff shows no changes), but yet the file is still marked as modified. – Andy Jan 25 '18 at 17:47
  • v2.16.0. I'm pretty sure I upgraded a week ago when it first released. – Mode77 Jan 25 '18 at 17:50
  • 2
    can you check what does git status output before git checkout alpha – cauchy Jan 25 '18 at 17:52
  • 8
    Reported and fixed: https://github.com/git-for-windows/git/issues/1437 – choroba Jan 25 '18 at 17:57

2 Answers2

2

This is a known bug in Git for Windows and it is fixed in v2.16.0(3). Updating to a newer version will fix this bug.

Thanks to @choroba for pointing out the reported issue!

Pieter
  • 3,262
  • 1
  • 17
  • 27
0

More recently, stashed files numbers might still not show up, with git status using porcelain v2 (presented here)

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

With Git 2.34 (Q4 2021), it now allows "git status --porcelain=v2"(man)to show the number of stash entries with --show-stash like the normal output does.

See commit 2e59e78, commit 612942a (22 Oct 2021) by Øystein Walle (Osse).
(Merged by Junio C Hamano -- gitster -- in commit dea96aa, 29 Nov 2021)

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 now includes in its man page:

Stash Information

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

stash

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250