What is the difference between rollback, backout and strip in the Mercurial Eclipse plugin?

后端 未结 1 1213
南笙
南笙 2021-01-30 08:20

What is the difference between the menu items rollback, backout and strip in the Mercurial Eclipse plugin?

Can I delete the commit in the local repository without modify

相关标签:
1条回答
  • 2021-01-30 09:08

    These commands all come from Mercurial itself, and there are plenty of good compare/contrast posts for them. However, here they are in brief:

    • rollback: one-level undo. Will undo the last pull or commit (can be dangerous)
    • backout: create a new commit that is the inverse of a given commit. Net effect is an undo, but the change remains in your history.
    • strip: remove (destroy) changes from history. Removing a changeset also removes all of its children, so it can only be used to truncate history, not remove a slice.

    All three are very well described here: http://www.selenic.com/mercurial/hg.1.html

    To your question 2, you could use strip to remove the most recent commit and it won't alter you working directory diles.

    To your question 3, you can easily make changes on another part of this project:

    hg commit -m 'commit your half done work'
    hg update OLDERCHANGESET # your working directory now is without the half-done-work
    .. do that quickfix ...
    hg commit -m 'quickfix'
    hg push tip # this pushes the tip revision (latest) and its ancestors, but the half-don't work isn't an ancestor so it doesn't get pushed
    hg update HALFDONEWORK # you can find the right revision number using "hg heads"
    

    That's call an "anonymous branch" and it's a very common way to work. You do end up committing the half-completed feature, but you can resume it later and you don't have to push it.

    This has a great explanation of anonymous branches: http://stevelosh.com/blog/2009/08/a-guide-to-branching-in-mercurial/#branching-anonymously

    0 讨论(0)
提交回复
热议问题