How to remove a commit in Mercurial?

I want to completely delete the Mercurial transaction, as if it had never been entered into the repository and did not return to the previous commit.

Is it possible?

+52
mercurial
Feb 22 '11 at 22:41
source share
8 answers

If this was your last commit, and you didn't push it anywhere, you can do it with rollback . Otherwise, no. Not really. Time to change your passwords.

Edit: It has been pointed out that you can clone from the old version and merge the changes you want to save. This is also true if you did not push it to a repo that you do not control. As soon as you click, your data will most likely be very difficult to return.

+32
Feb 22 '11 at 10:45
source share

You can try to remove the mq information about your commit.

  • To do this, you need to go to File-> Settings-> Extensions.
  • Check mq and restart gui.
  • After that, just right-click on the unnecessary commit and ModifyHistory-> Strip
+29
Dec 15 '11 at 12:28
source share

To edit the story, I would use the Histedit extension extension .

  hg histedit 45:c3a3a271d11c 

However, keep in mind that this only makes sense in a situation where you have not yet pushed commits to a public repository, you own a public repository, and / or you can take into account all the clones there. If you get the following error:

 abort: can't rebase immutable changeset 43ab8134e7af 

This means that Mecurial considers this to be a public set of changes (see phase ) that has already been clicked - you can make it be draft repeat:

 hg phase -f -d 45:c3a3a271d11c 
+9
Aug 29 '13 at 20:29
source share

I meet quite often. I do a commit and then click. But then there is something incoming that makes my newfound transmission unnecessary. A simple hg rollback not enough, because it cancels the click ...

This is what needs to be done:

 hg strip <rev> 

Things are painless when you don’t push your changes anywhere.

+6
Jan 13 '14 at 9:59
source share

You can use "hg backout" to do back-merging basically. All options are discussed in the freely available book "Mercurial: The Definitive Guide":

http://hgbook.red-bean.com/read/finding-and-fixing-mistakes.html

+5
Feb 22 2018-11-22T00:
source share

If this is more than one commit and / or you have already clicked it somewhere else, you can clone your repository and indicate the last set of changes to be cloned.

See my answer here how to do this:
Mercurial: fix borked history

If you just made a local attack and didn't click, you can just create a clone locally (as described in my link), and you're done.

If you have already clicked on any remote repository, you will have to replace it with your clone. Of course, it depends on whether you can (or are allowed to) do this.

+5
Feb 22 2018-11-23T00:
source share

If you use a turtle, you can use change history> strip ...

+3
Dec 04
source share

Yes. If I am mistaken since version 2.3 (link 2012/08/01) you can use the HisteditExtension with the drop command to remove the commit along with strip or backout to remove the changes.

A simple Google search for this feature: https://www.google.com/webhp#q=histedit+drop

+1
Jul 26 '14 at 19:57
source share



All Articles