I did some changes and then did a commit. Then I realized that I am on an unnamed branch. So I checked out another branch (with a name). Now I want to recover the commit that I did to the unnamed branch or switch back to the unnamed branch so that I can put a name on it.
Is my commit lost forever?
Is there a way to see a list of all commits to all the branches and unnamed branches?
You can inspect
git reflogto see what your HEAD was pointing at previously. When you find the commit id, you can check it out viagit checkout <commit-id>. Once you are on that commit, you can create a branch to point to it viagit checkout -b <branch-name>.