Issue
From git gui, I used gitk to git reset -hard
to a few commits before my current one, as I needed to test if everything was working before the changes.
Since I even had a few uncommitted changes, I git stash
in order to save them and being able to reapply them once going back to my last commit.
The problem is that gitk is not showing the top of my commit tree any more (the top commit is the current one and I don't see any commit above it)
It was sometimes since last time I used git, but I thought I can use git reset -hard to bring the current code to a previous version, and then git reset -hard to the old version.
How can I retrieve all the commit between the old HEAD and the revision I git reset -hard
to?
Please tell me there is some kind of way.
I'm using Eclipse as development tool (in case I'll need to use it's cache)
Solution
What you did could work if you had first make a new branch, before the first git reset --hard.
Because git reset
moved your current branch back, and those commits are no longer referenced by any branch (and not visible anymore)
You need to fallback to the command line, and try a:
git reset --hard ORIG_HEAD
# or
git reset --hard HEAD@{1}
ORIG_HEAD
or HEAD@{1} should have the SHA1 you were before the first reset.
If not, git reflog
can help (that is what HEAD@{1}
should be listed in).
Not, as alluding to in "ORIG_HEAD
and FETCH_HEAD
from history view in Eclipse", you should be able to see ORIG_HEAD
in the "History view" of Eclipse.
Answered By - VonC
Answer Checked By - Pedro (JavaFixing Volunteer)