Which VCSes have "uncommit"?

Teemu Likonen tlikonen at iki.fi
Thu Nov 5 17:54:18 GMT 2009


On 2009-11-05 16:41 (+0100), Daniel Carrera wrote:

> Does anyone know which distributed VCSes have an "uncommit" feature at
> least as powerful and at least as easy as the one from Bazaar?

These are the usual options in Git:

 a) Remove the last N commits and turn the commits' changes into
    changes in the working directory:

        git reset HEAD~N

 b) Remove the last N commits and also reset the working directory:

        git reset --hard HEAD~N

Instead of relative HEAD~N you can reset to any commit in any branch.
Just give a branch name, tag name, commit id SHA1 or some relative
pointer.

Git also has this thing called "reflog" which records branch pointers
locally _in time_. So, if you make a mistake and want to undo your last
reset command (un-uncommit) you can, for example, reset to where the
branch were 10 minutes ago:

    git reset --hard HEAD@{10.minutes.ago}

To actually see where your branch has been in time you'd use:

    git log --walk-reflogs

> I get the impression that Mercurial and Git can use "rebase" to
> achieve this, but that this is more complicated.

Rebase is wrong tool for this so no doubt it is more complicated.



More information about the bazaar mailing list