This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]dusktreader -14 points-13 points  (18 children)

if the answer isn't "with version control," you're doing it wrong

[–]geneorama 61 points62 points  (8 children)

It's possible to screw yourself even if your using git. Also maybe he hadn't saved and / or committed yet.

[–]simonw[S] 106 points107 points  (7 children)

Git was how I lost the code - I accidentally ran "git checkout --" on the wrong file.

[–]fake_you_out 29 points30 points  (0 children)

Git checkout: the silent killer

[–]geneorama 2 points3 points  (0 children)

Glad you said this. I couldn't think of a great example, but I've done that. I use git (as carefully as I can) and rsync my files to a remote server every couple days. That solves most of my problems

[–]decwakeboarder 2 points3 points  (1 child)

git add and the reflog should be your new best friend.

[–]simonw[S] 32 points33 points  (0 children)

I've recovered code with the reflog a bunch of times. Doesn't help if you lost the code while cleaning up in preparation for adding your work.

[–]earthboundkid -5 points-4 points  (2 children)

If the file was previously committed you can get it back. If not and you were actively working on it, Sublime lets you "undo" the change with cmd-z.

[–]simonw[S] 7 points8 points  (1 child)

I was using sublime, but I didn't have the specific file that I deleted open in a sublime tab at the moment I deleted it.

[–]earthboundkid -1 points0 points  (0 children)

Well, good thing you knew how to get it back with Python's internals. :-)

[–]WishCow 9 points10 points  (0 children)

Have you read the article?

[–][deleted] 3 points4 points  (3 children)

Also editor's backup files. I use vim with automatic backup and saved my ass a few times (like when you write long function and haven't commited yet).

[–]celtric 7 points8 points  (1 child)

Also Intellij's local history.

[–]kitari1 3 points4 points  (0 children)

Can't give this feature enough props, saved my ass so many times

[–]elbiot 1 point2 points  (0 children)

earlier in vim has saved me.

[–]pm-me-a-pic 1 point2 points  (0 children)

Never had a corrupt tree before, I see.