DEV Community

Discussion on: Recover a lost Git stash in two steps

Collapse
 
rstrausslogyx profile image
Randy Strauss • Edited

I tried both commands (git 2.21.1):
git update-ref refs/stash b68ecd901f90158d7c41edf2d2d3868e3599ca29 -m "My recovered stash"
git update-ref refs/stash b68ecd901f90158d7c41edf2d2d3868e3599ca29 --create-reflog -m "My recovered stash"

both give usage (below, removing the '-d' and '-stdin' stuff:
usage: git update-ref [] []
-m reason of the update
--no-deref update not the one it points to
-z stdin has NUL-terminated arguments
--create-reflog create a reflog

Is refs/stash the refname? Or is the sha the refname?
What's the "new-val" and "old-val" - values of what?

This page seems to help:
gist.github.com/joseluisq/7f0f1402...

git log --graph --oneline --decorate ( git fsck --no-reflog | awk '/dangling commit/ {print $3}' )
and then
git stash apply YOUR_WIP_COMMIT_HASH

Thanks for the hope, and being a stepping stone to most of what I needed. :?)

(4 of my files weren't stashed, though. It turns out NASA's backup utility has been silently failing for months, so I've lost a few days work. Under-staffed projects are a pain. Luckily, the project and my attitude don't really matter...)