On Sun, Feb 06, 2011 at 11:10:18AM +0100, Aristotle Pagaltzis wrote:
> * Michael G Schwern <[email protected]> [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.
--mixed
Resets the index but not the working tree (i.e., the changed files
are preserved but not marked for commit) and reports what has not
been updated. This is the default action.
--
Philippe Bruhat (BooK)
You are never too old to have your seat tanned by your Grandmother.
(Moral from Groo The Wanderer #41 (Epic))