Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HG: Undo a commit from history

I have a HG repository with revs 1, 2, 3, 4, 5 and 6.

When I committed rev 4, I unknowingly botched some changes in rev3 that I should not have. I did not notice this until rev 6 was already committed.

I need to undo changes in rev 4, but then re-apply all other changes after that. Basically undoing commit #4. How can I do that?

like image 362
Donn Felker Avatar asked May 06 '11 15:05

Donn Felker


People also ask

How do you rollback a commit in Heartgold?

If you want to revert just the latest commit use: hg strip --keep -r . Using strip will revert the state of your files to the specified commit but you will have them as pending changes, so you can apply them together with your file to a new commit.

How do you undo a pull in mercurial?

There is only one level of rollback, and there is no way to undo a rollback. It will also restore the dirstate at the time of the last transaction, losing any dirstate changes since that time. This command does not alter the working directory.

How do you revert push changes in mercurial?

You need to login to the server and use the hg strip command. If you cannot login to the server, you are out of luck; you can hg backout then push again, but this will leave the bad commits on the server along with the commit that undoes them. Show activity on this post. hg revert -r .


1 Answers

You want hg backout

Revert/undo the effect of an earlier changeset...

Backout works by applying a changeset that's the opposite of the changeset to be backed out. That new changeset is committed to the repository, and eventually merged...

like image 153
Jim Bolla Avatar answered Sep 27 '22 20:09

Jim Bolla