Somehow, I ended up with a detached HEAD. I made some commits and they showed up in my commit history as HEAD (but master was several commits behind). Then I tried to fix the detached head by checking out master.
Now I don't see my previous commits to the detached HEAD. Are they gone forever?
No. Check the reflog (
git reflog).