Sandra
Sandra

Reputation: 315

how to get data back after git reset --hard

So this is the situation. I was working on the server which don't have any backups. I knew there was old git rep which now is deleted. So I tried to upload everything to my new rep:

git init
git remote add origin ...
git push -u origin master

then i got some errors and did this:

git add .
git status

after that I saw all my filed in queue. that was good. then I did something awful...

git reset --hard

now somehow 80% of all files in directory are gone, I dont have any backup and don't know how to roll it back.. I tried these so far:

git reflog
git log -g
git reset --hard HEAD@{1}
git fsck --lost-found (don't even know why, just tried everything)
git rebase ffff3f3400153fba************ (last blob I saw)
git fsck --cache --unreachable $(git for-each-ref --format="%(objectname)")
git reset --hard @{1}

and still nothing. is there any way to roll it back as it was?

Upvotes: 0

Views: 80

Answers (1)

jbu
jbu

Reputation: 16121

Added files that are lost by git reset --hard or some other means will be put in the lost in found. In the case where git fsck --lost-found doesn't show the missing files, navigate to /.git/lost-found/other and do a grep (search) for your files.

Upvotes: 1

Related Questions