DEV Community

Cover image for Recover Lost Deleted “Git stash” using “Git fsck”
Egit S.
Egit S.

Posted on • Originally published at esabook.wordpress.com on

Recover Lost Deleted “Git stash” using “Git fsck”

1- Open Repository Directory in Terminal / Git Bash.

git fsck | awk ‘{print $3}’ > ids.txt
cat ids.txt | xargs git show > logs.txt

2- Then open ​logs.txt, and find deleted stash id.

example:  
commit a31b0a30701933cfb3d8a55cd4b96320865ae558  
Merge: c465de7 57a3521  
Author: Egit Saputra \  
Date: Tue Feb 19 14:37:29 2019 +0900  
On development: deleted stash test

3- and recover with git stash apply to current active branch.

git stash apply a31b0a30701933cfb3d8a55cd4b96320865ae558

Top comments (0)