Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git refs/stash not empty but running git stash list shows nothing

Tags:

git

On a Git repository, I can run the following:

$ git stash list
$ cat .git/refs/stash
22bfcca84458f21e63d37160a03f0cd5355517f2

So the stash list command shows an empty stash, but there is a stash reference. I'm trying to understand what is going on here. First of all, is this even a valid state? I presume the answer is yes, and that there is some cleanup that needs to run. But when I've done the following I get the show error:

$ git fsck --full
Checking object directories: 100% (256/256), done.
Checking objects: 100% (37/37), done.
$ git gc
fatal: error ummapping packed-refs file .git/packed-refs: Invalid argument
error: failed to run pack-refs

Any idea what is going on here?

like image 429
Ryan Sandridge Avatar asked Dec 06 '25 02:12

Ryan Sandridge


1 Answers

Well, I can't say I completely understand what happened, but I think everything is back to normal. I noticed that .git/packed-refs was an empty file, so on a backup of my repo, I did the following:

$ rm .git/packed-refs
$ git fsck
Checking object directories: 100% (256/256), done.
Checking objects: 100% (37/37), done.
$ git gc
Counting objects: 166, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (154/154), done.
Writing objects: 100% (166/166), done.
Total 166 (delta 73), reused 34 (delta 9)
$ git stash list
$ cat .git/refs/stash
cat: .git/refs/stash: No such file or directory

I'm answering here on the off chance it helps someone else. I don't completely understand what went on here. Comments welcome.

like image 109
Ryan Sandridge Avatar answered Dec 08 '25 14:12

Ryan Sandridge



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!