I deleted the stash while applying. And then by mistake reverted everything. How can I get it back? Please help.
Unless you have a backup somewhere else, this is difficult. However stashes are stored as regular git objects and provided this was done recently then the commit object will still be there and not garbage collected yet, it just won't have any references to it.
You can list all unreachable commits , but you have to drop to the command line (click Terminal on the toolbar). Then type:
git fsck --unreachable
This will show you all the commits which are not reachable by a branch / tag and which haven't been garbage collected yet. Look for the ones that say 'unreachable commit', ignore the blobs. The chances are it will be the one closest the top, unless you've performed some other actions which created more unreachables. You can examine the commits by doing 'git show <sha>', and this should identify the stash, it'll probably be called 'On master: <your comment>' or similar. Once you've found it, copy the SHA.
To recover this you then do:
git stash apply <sha>
Which will bring it back into your working copy.
Going through each commit through the terminal is quite combersome. But atleast there is a solution. Thanks :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Very helpful. Just used this to help out a co-worker. Thank you! :-)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Worked like a charm.. Thanks a lot saved my 4 hours of work.. :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You sir, are my hero, thank you!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You make my day sir, thanks a lot
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you!! Almost lost a day of work :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
How to retrieve :
git fsck --no-reflog | awk '/dangling commit/ {print $3}' | xargs git show > dangles.txt
search and select the commit you want and do below
git stash apply dec98ac9eb98abf94f43beecdf07f9c17e678ce1;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
God bless u man, Thanks a lot
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks alot :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Just saved my bacon, thank you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This was a life-saver ! Thanks !
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you so much for this answer!
This just saved me from a lot of headache.
It took a while for me to find the right commit, but I found it in the end. :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you very much! You saved day of my work!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you, sir!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You Sir are a life saver.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Really Helpful. Thanks Alot.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@anirudh reddy you saved my life today with your solution!!!! thanks a million
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks! Helped me a lot!!!!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This saved my day ! Thank you !!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you so much. Same problem I had today. For mistake I clicked delete stash and this answer helped me a lot!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thx a lot!!!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Brilliant! This outputs the details to a file so you can search for whatever you may have accidentally nuked.
git fsck --no-reflog | awk '/dangling commit/ {print $3}' | xargs git show > dangles.txt
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
How to retrieve :
git fsck --no-reflog | awk '/dangling commit/ {print $3}' | xargs git show > dangles.txt
search and select the commit you want and do below
git stash apply dec98ac9eb98abf94f43beecdf07f9c17e678ce1;.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
♡^▽^♡
♡^▽^♡
♡^▽^♡
♡^▽^♡
♡^▽^♡
♡^▽^♡
♡^▽^♡
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks you for this! It saved my life!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks a lot for this. Saved my day.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for this so much!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.