* Michael G Schwern <schw...@pobox.com> [2011-02-06 06:45]: > Here is your git undo button. > > [alias] > undo = reset --hard HEAD^
Except for the `--hard`, which will throw away changes in the only place where git cannot recover them: the working copy. You probably want this instead: git stash git reset --hard HEAD^ git stash pop It will move your HEAD ref back one commit and throw away the changes from that commit, but will preserve any delta between it and your working copy. If too much has changed you’ll get a merge conflict, but the stash will be kept. So you can reset the reset and re-apply the stash on the commit it came from – which gives you the exact same state that you started with. (And in any case, stashing makes a record of the state of your working copy in git, which makes it hard to lose that data entirely.) THIS is a git undo button. Regards, -- Aristotle Pagaltzis // <http://plasmasturm.org/>