Reputation: 7490
I am new to git. I have stashed my changed before starting to work on other branch. When I was done with that I came back and saw my stash. One new file is missing from the stash that I added, rest of the files are there. I also deleted that file from Changes
since I though it is safe in stash
. Is there any way to get that file back?
Upvotes: 1
Views: 258
Reputation: 430
If you've never added that file, it's almost gone but if you have, here is a weird way to find it.
Run this command where your '.git' folder is.
find .git/objects | sed -n 's_.git/objects/\(.\{2\}\)/\(.*\)_\1\2_p' | xargs -n1 git cat-file -p | grep "content" -A 20 -B 20
And Replace content
with something that you know it was in your file content.
Hopefully, You'll find that file then you can change -A and -B params to print the whole file.
find
.sed
xargs
and git cat-file
and search for the blob
containing the file we want.Upvotes: 8