L
21

Rant: Lost a whole afternoon because I didn't commit my code before a merge

I was working on a simple website project last Tuesday, sitting in my home office around 3 PM. I had about 4 hours of changes to a CSS file and some new JavaScript functions. Before I knew it, git decided to auto-merge something and it overwrote all my work from that day. Turns out, I was on the wrong branch the whole time and never committed first. Has anyone else had git eat hours of work like this?
2 comments

Log in to join the discussion

Log In
2 Comments
jamieburns
jamieburns15d ago
Yeah this is a classic git trap. First thing I do now before any merge is stash my work if I haven't committed yet. `git stash` saves everything locally without a commit, then you can pop it back after the merge. Also worth getting in the habit of checking `git branch` before you start working. I started keeping a terminal window split with the branch name visible so I can't miss it. Lost a whole Friday afternoon once to the exact same thing. Never again.
6
foster.dylan
foster.dylan15d agoMost Upvoted
Stashed a whole React app once and forgot about it for three weeks, thought I'd lost my mind.
9