How to revert last commits and keep changes in mercurial?

后端 未结 2 799
失恋的感觉
失恋的感觉 2021-02-13 13:46

I have three commits 1, 2 and 3. How can I rollback 2 and 3 and still keep the changed files of them??

1---2---3

=> 1 and changed files of 2 and 3

2条回答
  •  面向向阳花
    2021-02-13 14:01

    You use the strip command:

    strip changesets and all their descendants from the repository

    with the --keep option:

    -k --keep do not modify working copy during strip

    And since strip is destructive of history it's not enabled by default. You enable it by adding these lines to your ~/.hgrc file:

    [extensions]
    strip =
    

    So in this case you'd do hg strip --keep 2

    Note: requires Mercurial 2.8 or later. Before that you need to put mq = in the .hgrc instead.

提交回复
热议问题