Anyone ever lost uncommitted work after git reset --hard?
I just lost three hours of work... I habitually only ran add and never committed.
Does anyone know how to recover it? ㅠㅠ
7 answers
T_T I've been there too, so since then I've made sure to commit every 10 minutes no matter what
If you use VSCode, check out the Timeline tab. It keeps local history, so you might be able to recover it. IntelliJ also has Local History.
reflog is commit-level, so it won't help in this case; as the person above said, fsck is the answer. But honestly, if it's three hours, it might be faster to just rewrite it lol
Does reset --hard really wipe out uncommitted work? That's not quite right. --hard resets tracked files to the HEAD state, and it doesn't touch newly created untracked files. I'd say the first step is to figure out exactly what you actually lost.
Got a source? Have you actually tested whether fsck can recover it?
You said you ran git add, right? Then we can recover it. Run git fsck --lost-found and you'll get a list of dangling blobs. Open each one with git cat-file -p <hash> and look through them to find it. The moment you add a file, its contents are saved as an object. Even if you didn't commit, it was staged. The catch is that the filename info is gone, so you'll have to dig through blobs that contain only content. If you've been at it for three hours, there probably aren't many files left, so you should find it quickly. Don't run any more commands in that repo from now on. If gc runs, it's really over.
Every time I see a post like this, I’m reminded that the habit of only running add and never committing is genuinely dangerous. Staging isn’t saving—it’s just a temporary marker... Think of what you went through today as the price of a lesson. If you build the habit of making a commit every time you finish a feature, this loss will become a lifelong asset. That’s how I learned it.