Comment by fragmede

2 days ago

Reflog is your friend.

    git break-my-shit
    git reflog
        ... output saying where you were before things broke
        ... grab the good commit sha
    git reset --hard good_commit_sha_from_reflog

The copy-the-.git-dir trick works for worse issues than can be solved with a single reset --hard. Damn near anything, really, as long as you haven't touched any remotes. It also works if you don't remember/understand how you broke it, where it's broken, or which state you need to try to reset to.