What's the best way to back out multiple changesets in mercurial?

前端 未结 5 764
Happy的楠姐
Happy的楠姐 2021-02-13 01:33

Is the most reliable method to go one-by-one, using the backout command for each of many changesets, or is there a way to create one big reversal changeset to cover a whole bunc

5条回答
  •  悲哀的现实
    2021-02-13 02:22

    This is how you can do it with TortoiseHg. Of course you can do the same with the command line.

    Given this history, where you wan't to get rid of changeset A, B and C:

    1 -- 2 -- A -- B -- C -- 3 -- 4
    

    First update to revision 2.

    Then rebase the first of any later revisions you wan't to keep - in this case revision 3.

    Your history now looks like this:

    1 -- 2 -- A -- B -- C
          \
           3 -- 4
    

    Now update to revison 4.

    And finally use "Merge with local" to merge revision C onto revision 4.

    At this point it is crucial that you select the option "Discard all changes from merge target (other) revision".

    The description may not be the most logical, but it means that you merge the old tip C back to the default branch - but without the changesets A, B and C.

    The result is:

    1 -- 2 -- A -- B -- C --
          \            /
           3    --    4
    

    Commit and you're done.

提交回复
热议问题