I frequently use git stash
and git stash pop
to save and restore changes in my working tree. Yesterday I had some changes in my working tree that I had stashed and popped, and then I made more changes to my working tree. I'd like to go back and review yesterday's stashed changes, but git stash pop
appears to remove all references to the associated commit.
I know that if I use git stash
then .git/refs/stash contains the reference of the commit used to create the stash. And .git/logs/refs/stash contains the whole stash. But those references are gone after git stash pop
. I know that the commit is still in my repository somewhere, but I don't know what it was.
Is there an easy way to recover yesterday's stash commit reference?
Note that this isn't critical for me today because I have daily backups and can go back to yesterday's working tree to get my changes. I'm asking because there must be an easier way!
git stash pop
, you can dogit stash apply
instead. It does the same thing, except it doesn't remove the reference to the applied stash. – Kevingit stash
,git pull -r upstream
,git push -f origin
,git stash pop
, and pop said "fatal: log for refs/stash is empty". 😲 I tried a bunch of these answers, nothing worked. When I looked in .git/refs/stash, the SHA was in there. Maybe a problem with marking a Windows network drive for offline sync? 🤷♂️ – brianary