Hacker News new | past | comments | ask | show | jobs | submit login

git reset --hard



Generally 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.


You missed the point of the '--hard' argument. It destroys the local, uncommitted changes.

That can be much scarier than 'git push -f'.


Apparently 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.


I'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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: