Reputation: 579
My last commands were:
git rebase -i HEAD^^
git rebase -i HEAD^^
git rebase -i HEAD^^^
How do I get the repository back to the state it was in before the first of the listed commands?
NOTE: all I have been doing thus far is git commit -am "my commit message"
. I don't understand branching and merging yet so I haven't used them. I was trying to roll back the code to the previous commit, but this didn't seem to do anything.
Upvotes: 4
Views: 2732
Reputation: 38148
If those are the exact commands you've run, then git reset --hard HEAD@{3}
will get you back to your HEAD as of 3 commands ago. More generally, look at the output of git reflog
to come up with the ref you want to recover, and then git reset
to that.
Upvotes: 8