4 ms·
"CAUTION: several people I know, including guys very proficient in Git, have complained about "git ate two days worth of my work!". It is easy to make errors in
by ef4 15y ago
"CAUTION: several people I know, including guys very proficient in Git, have complained about "git ate two days worth of my work!". It is easy to make errors in rebasing and reset --hard, and you may end up losing commits."
Like everything else in git, the solution to this problem is just to make more branches.
If you're about to do something like a rebase, just fork off a new branch first. It makes it trivially easy to get back where you started if something goes wrong. That's the whole point of version control, after all.
- lparry 15y agoNo need to make a new branch, just look in git-reflog and pick out the sha you want to reset --hard back too
- deleted 15y ago[deleted]
- gruseom 15y agoseveral people I know, including guys very proficient in Git, have complained about "git ate two days worth of my work!" It is easy to make errors in rebasing and reset --hard, and you may end up losing commits. Something seems wrong there. How do you lose commits? They're all in the reflog. The only way I can see git "eating" work is if the work hadn't been committed in the first place and they overwrote it - in which case it's not so much "git ate my work" as "I deleted it". It's true that it's easy to make errors with rebase and reset, but it's just as easy to correct them. That's the beauty of it: commits are so malleable that they become part of interactive hacking. One gains a new axis along which to store information and move it around and rework it (comparable to a bunch of new registers magically appearing in a machine). For me the most interesting consequences don't have to do with version control so much as with how I craft programs in general. Biggest win since the REPL.