Mercurial undo last commit

后端 未结 8 666
既然无缘
既然无缘 2020-12-02 06:11

How can I undo my last accidentally commited (not pushed) change in Mercurial?

If possible, a way to do so with TortoiseHg would be prefered.

Update<

相关标签:
8条回答
  • 2020-12-02 06:41

    hg rollback is what you want.

    In TortoiseHg, the hg rollback is accomplished in the commit dialog. Open the commit dialog and select "Undo".

    alt text

    0 讨论(0)
  • 2020-12-02 06:42

    Since you can't rollback you should merge that commit into the new head you got when you pulled. If you don't want any of the work you did in it you can easily do that using this tip.

    So if you've pulled and updated to their head you can do this:

    hg --config ui.merge=internal:local merge
    

    keeps all the changes in the currently checked out revision, and none of the changes in the not-checked-out revision (the one you wrote that you no longer want).

    This is a great way to do it because it keeps your history accurate and complete. If 2 years from now someone finds a bug in what you pulled down you can look in your (unused but saved) implementation of the same thing and go, "oh, I did it right". :)

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