5 ms·
git reset --hard
by hvis 11y ago
git reset --hard
- slavik81 11y agoGenerally recoverable by checking git reflog and doing another git reset --hard back to how it was before. git clean -dfx is the most probable way for me to delete something that I never committed.
- hvis 11y agoYou missed the point of the '--hard' argument. It destroys the local, uncommitted changes. That can be much scarier than 'git push -f'.
- slavik81 11y agoApparently we both need to write better, because you missed the point of my example. Most—if not all—local changes that would be destroyed by git reset --hard show up in git status. git clean -dfx will wipe out ignored files, which do not show up in git status, so it's much easier to forget about something you meant to keep.
- hvis 11y agoI've never used 'git clean -dfx' routinely during development. On the other hand, I've seen a colleague lose a few hours' work by forgetting to commit a specific file out of a set, and then doing 'git reset --hard' for some reason. 'git status' didn't save him. Luckily, he did commit the corresponding tests file.