Git reset hard and going backwards

From the git gui, I used gitk for git reset -hard

up to a few commits before my current one, since I needed to check if everything was working before making changes.

Since I even had a few uncommitted changes, I git stash

have to save them and be able to reuse them by reverting back to my last commit.

The problem is that gitk no longer shows the top of my compilation tree (the top commit is the current one and I can't see any commits above it)

I've used git sometimes with the past, but I thought I could use git reset -hard to bring the current code back to the previous version, and then git reset -hard to the old version.

How can I get all commits between the old HEAD and the revision I have git reset -hard

before? Please tell me some way.

I am using Eclipse as my development tool (in case I need to use its cache)

+3


source to share


1 answer


What you did might work if you created a new branch first, before the first git reset --hard.

Because git reset

moved your current branch back
and those commits no longer reference any branch (and are no longer visible)

You need to step back at the command line and try:



git reset --hard ORIG_HEAD
# or
git reset --hard HEAD@{1}

      

ORIG_HEAD

or HEAD @ {1}
must have the SHA1 you were before the first reset.
If not, git relog

might help (here's what to point out HEAD@{1}

).

No, as stated in " and from viewing history in Eclipse ", you should see it under " Browsing history " in Eclipse. ORIG_HEAD

FETCH_HEAD

ORIG_HEAD

+3


source







All Articles