Not sure why you are unable to find your commit, as @twalberg's comment about git reset --hard
is correct. Here are some things to try, though.
You have the message for the commit you're looking for (.git/COMMIT_EDITMSG
). If COMMIT_EDITMSG
was written, then that particular commit should be somewhere. Pick out some text from the message that is fairly unique and try this:
git log -g --grep="<something specific from your commit message>"
It will go through the reflog and find commits that match text from your lost commit's message.
If no luck with that, you can try looking through all commits on every branch:
git log --all --grep="<something specific from your commit message>"
Once you find the commit hash, you can check it out, make a new branch, merge it back into your current branch, etc.
However, if that all fails you can try looking though objects that are in the repository, but aren't part of any commit (e.g., added to the index, but not committed.) This answer can help you with that: