Ephra
Ephra

Reputation: 111

rollback to original state after git revert

I have done a git revert by mistake in my project and all files return to old version. How can I rollback (restore) my project back. I have worked for almost weeks without commit anything so now all my changes have gone. Any help please

Upvotes: 2

Views: 244

Answers (1)

VonC
VonC

Reputation: 1327734

A git revert should have introduced a new commit.
You can reset your branch to the previous commit and see if you get back your files.

You can try, on a clone of your current repo:

git clone repo1 repo2
cd repo2
git reset --hard HEAD~

(if that doesn't work, the fact that the reset has been done on a clone means you have erased anything on your current original repo)

If the previous commit didn't contain any of your current work, then you need to check if you at least added to the index your work (git add), even without committing.

In that case, you can use a git fsck --full to look for your content.
See "Different versions staging area?" for some ideas.

Upvotes: 2

Related Questions