F
3
c/coding-for-beginnerswyatt135wyatt1359d agoTop Commenter

Lost 3 hours of work because I forgot to save before a git rebase

Was at my kitchen table at 2am trying to clean up some commit history on my first real project. Typed git rebase -i HEAD~5 and thought I knew what I was doing. Hit save and exit and boom - merge conflicts everywhere. Panicked and did git checkout . to 'fix' it and lost every change from the last 3 sessions. Didn't have any branches to fall back on. My buddy on Discord told me about git reflog the next day but by then the damage was done. Anyone else destroy their own code trying to be fancy with git?
3 comments

Log in to join the discussion

Log In
3 Comments
murray.cora
Reflog is one of those things you never think about until you need it - so did your buddy walk you through how to actually use it, or was it more of a "yeah that exists" kind of tip? Because even knowing the command doesn't mean much if you don't understand how the commit hashes work in that list, you know?
3
hayden_craig95
That reminds me of the time I spent an hour trying to recover a file I accidentally deleted in a terminal... turned out I was in the wrong directory the whole time. Just one of those days where you learn more from screwing up than any tutorial could teach you.
6
taraross
taraross9d ago
Nah, learning the hard way is how you actually remember reflog exists.
2