Hacker News new | ask | show | jobs
by ricardobeat 3589 days ago
Warrants a big warning that using `reset --hard` will irreversibly wipe out any uncommitted changes.
2 comments

Also doing `git checkout -- filename` will lose the changes to that file permanently. The only feature I miss from Bazaar was that it would create a backup file automatically for its equivalent command. I have actually created a bash function that overrides git to add this functionality (since there is no pre-checkout Git hook and Git doesn't allow you to create an alias named "checkout").
Came here for this. git undo won't restore the changes wiped out by reset --hard? They aren't stored on the reflog?
If it hasn't been committed, it won't be in the reflog. Working copies and stashed changes are especially vulnerable to being overwritten by accident. It would be great if git had a way to undo these operations too.
You could alias reset to instead commit all and then reset.
But what if I'm just trying to unstage something? I don't think shell aliases can solve this in the general case.