by steveklabnik · 6y ago · 0 comments
git reflog is very useful for this. Also, when you delete a branch, git helpfully prints
Deleted branch foo (was da2bb5d)
so you already have that information, right there.
When I started using git, I checked out back in time, then git logged and was baffled to not see my most recent commits in the listing. I panicked, though I lost my work.
Git terrible UI didn't help there: who though it was a good idea to just hide everything with no hint of how to get back at it?
Of course, I could have just git checkout master to get back where at was, I just didn't know it. But that's the point of reflog: if you are not sure what you did or where you are, it's always there for you, it has your back.