0

Here is the situation. I made a merge (commit 80d0e2b on the picture) of my branch and origin/master and pushed my changes to remote server. The merge appeared to be shitty and I decided to apply git reset HEAD~1 to remove it from server (yes, I was stupid). Now I ended up in situation, when some of the commits (for example, MOB-25) are not reachable from any branch and commit 2e4df35 is the referred as the last.

I thought about changing the point of origin/master to point to MOB-25 and then to apply fetch and make merge again.

I also found this thread advising to use reflog (How can I undo git reset --hard HEAD~1?), but I want to be 100% sure. What would be the best way to fix this mess? enter image description here

Community
  • 1
  • 1
Konstantin Milyutin
  • 11,946
  • 11
  • 59
  • 85
  • 1
    @Andrew Aylett: damluar wants to be "100% sure" that it's a duplicate, though. ;) But yeah, it's a duplicate. Worth keeping this question open, though, it's a better-worded question than the terse original, although the original has better answers... – Arafangion Jul 15 '13 at 14:54

1 Answers1

1

Your only options are to use git reflog to to find the historical list of sha1 commits you have been on... And your backups.

Once you've found the commit you wanted, tag or branch from it so that it appears in your log.

Heck, tag all the reflog lines that indicate 'MOB-25' if you want, with different tags, and take a look at the revision tree using gitk or your preferred git program. When you've found the one you want, feel free to delete them.

To see the reflog:

git reflog

To create a tag:

git tag MOB-25a theSha1

To create a branch:

git branch theSha1 MOB-25a
Arafangion
  • 11,517
  • 1
  • 40
  • 72