Can't recover commit from Git due to same sha in reflog

I’m trying to recover code because I accidentally switched to a branch in eclipse and lost all my data, somehow (I still don’t know what I did). When I open up my git reflog in command line, I see:

6dc60f6 HEAD@{14}: commit: fixed class mismatch for integers
638fbb1 HEAD@{15}: commit: fixed first NPE bug
22fc2b9 HEAD@{16}: commit: v 6.0.5
0acef4f HEAD@{17}: commit: clean up
8a441cb HEAD@{18}: commit: cleaned up db code
9ac384d HEAD@{19}: commit: ver 6.0.4
ce1f1c2 HEAD@{20}: commit: addded drivers
9b5a4dd HEAD@{21}: checkout: moving from master to 9b5a4dde0f97303579ec0cf15413ecce83a636dc
6dc60f6 HEAD@{22}: commit: change Db
9b5a4dd HEAD@{23}: commit: // for public schema: "" or "public" 
f668dd1 HEAD@{24}: commit: changed schema
a0e5b2a HEAD@{25}: commit: changed frames

I’m trying to checkout 6dc60f6 HEAD@{14}: commit: fixed class mismatch for integers but all of my attempts to check it out go to 6dc60f6 HEAD@{22}: commit: change Db which is a much older version. This is from a git reflog command, not git log so checking out @{14} doesn’t work either.

Is there a way to checkout the lateset commit for 6dc60f6 or is that lost?

Thanks.

P.S. The other 14 commands are just me switching from one brach to another and back again trying to fix it.

638fbb1 HEAD@{0}: checkout: moving from 6dc60f6 to master
638fbb1 HEAD@{1}: checkout: moving from ce1f1c247f94298c9e1fd67f0e1199a82df2ff1c to 6dc60f6
ce1f1c2 HEAD@{2}: checkout: moving from 6dc60f6 to ce1f1c2
638fbb1 HEAD@{3}: checkout: moving from master to 6dc60f6
638fbb1 HEAD@{4}:
6dc60f6 HEAD@{5}: checkout: moving from 6dc60f6f81a9f97d6d1244a288bec027fd7604b6 to master
6dc60f6 HEAD@{6}: 
638fbb1 HEAD@{7}: checkout: moving from ce1f1c247f94298c9e1fd67f0e1199a82df2ff1c to 638fbb1
ce1f1c2 HEAD@{8}: checkout: moving from 9b5a4dde0f97303579ec0cf15413ecce83a636dc to ce1f1c2
9b5a4dd HEAD@{9}: checkout: moving from 638fbb18fbe0dfd7bca8477d7b9ddde44443ed4a to 9b5a4dd
638fbb1 HEAD@{10}: checkout: moving from 6dc60f6f81a9f97d6d1244a288bec027fd7604b6 to 638fbb1
6dc60f6 HEAD@{11}: checkout: moving from 638fbb18fbe0dfd7bca8477d7b9ddde44443ed4a to @{6}
638fbb1 HEAD@{12}: checkout: moving from master to 638fbb1
6dc60f6 HEAD@{13}: checkout: moving from 078b90ff9eb70560ecf5e9a25b1f7aaa7db9a81a to master
078b90f HEAD@{14}: checkout: moving from master to @{5}
6dc60f6 HEAD@{15}: checkout: moving from latest_branch to master
6dc60f6 HEAD@{16}: checkout: moving from new_branch to latest_branch
6dc60f6 HEAD@{17}: checkout: moving from master to new_branch

Edit 2:

Running git reflog show --no-abbrev, this is on a zip file of the repo before I did all those checkouts that flooded reflog so it starts at @{0}, note the 2 (HEAD, master) with same hash but different commit messages:

6dc60f6f81a9f97d6d1244a288bec027fd7604b6 (HEAD, master) HEAD@{0}: commit: fixed class mismatch for integers
638fbb18fbe0dfd7bca8477d7b9ddde44443ed4a HEAD@{1}: commit: fixed first NPE bug
22fc2b9e22e9259858f5d8df6b44fdd17e7ef475 HEAD@{2}: commit: v 6.0.5
0acef4fef3df6df7b6f77ef3d373f3071aafdc4a HEAD@{3}: commit: clean up
8a441cbfc8b68b25fe6cc2e96ed5cad797ba139c HEAD@{4}: commit: clean up db code
9ac384dfec998e3c7ea0641ba04025d5c0aa4abb HEAD@{5}: commit: ver 6.0.4
ce1f1c247f94298c9e1fd67f0e1199a82df2ff1c HEAD@{6}: commit: added drivers
9b5a4dde0f97303579ec0cf15413ecce83a636dc HEAD@{7}: checkout: moving from master to 9b5a4dde0f97303579ec0cf15413ecce83a636dc
6dc60f6f81a9f97d6d1244a288bec027fd7604b6 (HEAD, master) HEAD@{8}: commit: change Db
9b5a4dde0f97303579ec0cf15413ecce83a636dc HEAD@{9}: commit: // for public schema: "" or "public"
f668dd11646727dae7b8511796a88c59d439c2bf HEAD@{10}: commit: changed schema
a0e5b2a2c349ae0665f80fa1b7027836c8bbc6aa HEAD@{11}: commit: changed frames
2e934ffe0546413e7a7e81318f9e7aefc458e8d2 (origin/master) HEAD@{12}: commit: Change classes: BusinessRules - fix compliler error DBMetaInfopanel - fix dialog: MSDOC-ISSUE-007, MSDOC-ISSUE-010 ReportTable - fix DateTime and Number format Config.txt - add global DateTime and Number format add jar Profiler 6.0.4
078b90ff9eb70560ecf5e9a25b1f7aaa7db9a81a HEAD@{13}: commit: apply 6.0.3.2 fix and changed global parameters in Config.txt commented all DBs in Config.txt
9fb275d45da8e2df3044448b3275aa24a77ddd85 HEAD@{14}: commit: change framework version to 6.0.4
9835cdf1ba1d38bf3343e43623bd31f2aa0562b6 HEAD@{15}: commit: add Datetime and number format
839fa8b27a1c7a05fa19d75b5c62a8f35a865b9d HEAD@{16}: commit: add new profiler-6.0.3.4 remove profiler-6.0.3.1 change pom.xml
68acc9cfd9e0bc65159e35e832afa59d4d014717 HEAD@{17}: commit: add 6.0.3.1
46b0d9c2c8d4ac81f951ae41e2f405c864f430b0 HEAD@{18}:

  • git reflog expire and git fsck --unreachable
  • why doesn't my git reflog go back up to clone
  • unstaged files gone after git reset --hard
  • What is the most robust way to get the name of the reference last pointed to by HEAD?
  • Getting the sha1 of a desired commit from a remote repository
  • git reflog not showing branch change
  • Is there a way to cause git-reflog to show a date alongside each entry?
  • which commit was cherry-picked?
  • 2 Solutions collect form web for “Can't recover commit from Git due to same sha in reflog”

    The problem is that git reflog abbreviates hashes to 7 characters, but the first 7 characters in these two commits are the same.

    To get the full hash with reflog, use this command:

    git reflog show --no-abbrev

    Then, you can use the full hash to checkout the commit you want.

    Solved using:

    gitk --all $( git fsck --no-reflog | awk '/dangling commit/ {print $3}' )

    from:

    How to recover a dropped stash in Git?

    Git Baby is a git and github fan, let's start git clone.