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

1

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)

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay