6 ms·
I've been using Git for a couple years now, and I don't think I've ever lost any work. Even if you do `git reset --hard HEAD~5`, "throwing away" your last few
by billybob 14y ago
I've been using Git for a couple years now, and I don't think I've ever lost any work.
Even if you do `git reset --hard HEAD~5`, "throwing away" your last few commits, they aren't actually discarded yet. You can do `git reflog` to see them and then `git checkout -b some_commit_hash` to recover one to a branch, or `git reset --hard some_commit-hash` to set this branch back to that point.
Only if those commits stay orphaned for a while (a week or two?) will Git truly discard them.
- Xurinos 14y agoIt becomes dangerous if you have changes in your working tree. You truly lose those changes with a "git reset --hard HEAD" or the forced checkout.