How to revert a Mercurial hg pull?

前端 未结 5 1832
孤独总比滥情好
孤独总比滥情好 2021-02-13 14:46

If you do an hg pull and then an hg update (or an hg merge), is there a way to back this out? Ie: revert your repository to the state pri

5条回答
  •  [愿得一人]
    2021-02-13 15:37

    Ok, you can't rollback because you've done a commit. What you can do is use 'hg strip' which is part of mq (after 2.8 strip is in it's own extension), or use mq to remove the changes. Either way I suggest you do everything on another clone, just in case.

    To do strip, update to a revision that you want to keep, and then

    hg strip 
    

    where is the first revision you want to remove. It will remove that one and all decendents (including your merge commit).

    Alternatively you can

    hg qnew (if you don't already have a patch queue)
    hg qimport 
    

    which will import a single revision into the patch queue. You can then add more, and then use the mq commands to edit, rearrange, delete, or whatever you want to do with those revisions. qdel deletes the current patch.


    Edit: Obviously, you'll need to enable the MQ extension for both of these, unless you're using 2.8 or later. In that case strip is in the strip extension, and mq in the mq extension. Both are shipped with the standard installation.

提交回复
热议问题