Monday, November 9, 2020

Undo git stash clear

You can clear git stashes using the command:
git stash drop stash@{stash_index}
### OR
git stash clear
If you need to recover very recently deleted stashes, you can try the following two commands to try to recover them:

1. List all the available stashes that can be receovered using the below command:
git fsck --unreachable | grep commit | cut -d ' ' -f3 | xargs git log --merger --no-walk
2. Choose commit id of the stash that you want to restore and run the below command:
git stash apply [commit_id]

No comments:

LinkWithin

Related Posts Plugin for WordPress, Blogger...