So, I was doing some basic engineering project at uni with a teammate but we didn't realize that we were working in a detacted head state in git (due to poor set up of the working environment on his part).
After a 3,5 hours of work, we need to push to the repo and we get an error.
I take control to try to understand what was going on, and in doing so, I (mistakenly?) check out to another branch.
Git garbage collector kicks in and we can't checkout to the previous branch anymore (where all the work was made).
My friend panics and calls the professor, who explains to us how we lost everything and there is "a 100% no hope of recovering our work".

Felt like poop. But wasn't satisfied. I had read somewhere that you don't lose stuff so easily on git. Went home.
After five minutes I was able to recover everything through git reflog feature.

Moral #1: professors should know about the existence of reflog

Moral #2: please use git plug-in in your bash /zsh. Please.

  • 1
    Cool head.
    Don't panic.
    Almost everything is fixable.
Add Comment