Skip to content

Latest commit

 

History

History
24 lines (16 loc) · 718 Bytes

2014-02-20.md

File metadata and controls

24 lines (16 loc) · 718 Bytes

Deepak

undo a dropped git stash

let us say we drop a stash accedently
and now we want to recover it

we can:

  1. see the dangling git stashes ie. code which is unreachable

git fsck --unreachable | grep commit | cut -d ' ' -f3 | xargs git show

  1. take a sha and create a patch

assume SHA is 3202c4c4cb1e14b43954fb6f1d24552bc45e86bf

git format-patch --stdout head..3202c4c4cb1e14b43954fb6f1d24552bc45e86bf > /tmp/patch
git apply --stat /tmp/patch
git apply --check /tmp/patch
git am /tmp/patch
git commit --amend to edit commit message

googled when faced with this problem now
https://github.com/abhikp/git-test/wiki/Recovering-a-lost-stash helped