How do you “rollback” last commit on Mercurial?

后端 未结 3 474
梦毁少年i
梦毁少年i 2021-02-01 00:36

I have a Mercurial repository that I use in local only... It\'s for my personal usage (so I don\'t \"push\" anywhere).

I made a commit with 3 files, but after that I und

3条回答
  •  后悔当初
    2021-02-01 00:46

    The answer is strip (if you don't have it enabled you can check how to enable it here: https://stackoverflow.com/a/18832892/179581).

    If you want to revert just the latest commit use:

    hg strip --keep -r .
    

    If you want to revert to a specific commit:

    hg strip --keep -r 1234
    

    Using strip will revert the state of your files to the specified commit but you will have them as pending changes, so you can apply them together with your file to a new commit.

    Recover your stripped data:

    If you miss-used the command or you want to recover your changes you can find your stripped files in the .hg/strip-backup folder.

    Tutorial on how to restore your files, or just google for it (works the same on all OS).

    Credit to ForeverWintr

提交回复
热议问题