I have carelessly done a checkout from an undetached branch to my main branch without pushing all locally committed files… Have I irreversibly lost all files and updates?
By “undetached branch” do you mean “detached HEAD”, which means commits not on a branch? In that case you should be able to find your commit in the output of
git reflog. The reflog shows you a list of commits that HEAD pointed to in the past, as it changes with commits, checkout, and so on.
“Loose” objects will be cleaned up after 2 weeks by default, so if this is a recent issue your commit(s) should still be there.
That’s exactly what I was asking for, thank you so much!