That's why you should use control version.
Though recently I lost one file somehow, because it was not tracked by Hg and I didn't want to commit it while it was not tested properly. Now I'm rewriting 1 KLOC.
It was sign to learn branches so I can commit even unfinished code.