James Wuhan
James Wuhan

Reputation: 35

Removed main commit in github repo

Help guys, I just did a git reset on my main commit in a git repo, now the whole project has gone back to the start?

When i do git reflog i can see my previous commits still, how can i move to one of them and restart from there.

Anyway, I can recover this? Major error

Upvotes: 0

Views: 36

Answers (1)

Acorn
Acorn

Reputation: 26116

Create a new branch, check it out and then reset it to the commit you see in the reflog:

git branch recover
git checkout recover
git reset --hard <commit-from-reflog>

This should give you the state you had at that point, including in the working directory.

Upvotes: 2

Related Questions