nonopolarity
nonopolarity

Reputation: 151146

Using Mercurial, if you commit, can you get back to the original state before you commit?

hg backout tip seem to also revert all your files back to the older version. Is there a way to change it back to EXACTLY like before the commit -- that is, with several files "Modified" but uncommitted -- essentially, as if the "commit" was never done?

(hg rollback is said to be very bad and usually shouldn't be done for version control purpose)

Upvotes: 1

Views: 210

Answers (2)

leoger
leoger

Reputation: 1074

Once you push, of course, there is no tool that will do what you want. That being said, if you have more than one changelist that you want to remove from your local history rather than just undoing their effect with hg backout, then you can use hg strip, which is available as part of the MQ extension package.

You can do the following to get your desired effect:

hg export tip > foo.patch

hg strip tip

hg import --no-commit foo.patch

Upvotes: 2

sth
sth

Reputation: 229754

hg rollback does exactly what you are asking for - it undoes the hg commit and you end up in the state you were before you committed.

Of course it's not really in the intention of a version control system to "lose" versions you already committed, but it's handy to revert an accidental commit.

Upvotes: 3

Related Questions