Remove a revision in TortoiseHG and Mercurial

2019-05-03 14:12发布

问题:

In my repository I needed to revert to an older revision. I did reverting and made the changes I needed to. How do I push the new revision upstream?

I was on rev 17 when I needed to revert back to rev 13. Now that I've made my changes, I'm on rev 18. Thing is, when I go to push these changes up (I'm using TortoiseHG), I get an error "abort:push create new remote head.

I don't want to do a merge. Do I want to do a force with the --force command or do I need to delete rev 14-17. If I need to delete, how do I delete 14-17.?

回答1:

Proper solution is to actually merge with option Discard all changes from merge target (other) revision. But sometimes life is harder on us and we really need to drop some changes (eg. we committed nuclear launch codes or some other security sensitive data). Is that your case? If yes then follow.

Assuming that original changes were not published you could:

  • enable mq extension
  • r-click on offending changes and execute Modify history->Strip. This will permanently remove changes from your local history.


回答2:

You don't want to delete revisions and therefore destroy history. That goes against the reason version control exists.

You can do a merge and discard.

You can also do this in tortoiseHG.