How to get rid of some changeset in Hg?

前端 未结 5 1253
青春惊慌失措
青春惊慌失措 2020-12-29 14:50

Hey, I want to revert some changesets in Hg but I\'m having a hard time doing so.

I commited some changes by accident, so I wanted to undo that. After trying a littl

5条回答
  •  清酒与你
    2020-12-29 15:29

    You've got some good answers already, but a couple additional notes:

    • If you've got uncommitted local changes, shelve will set them aside for you for later retrieval
    • If your changeset has been pushed to another repository, then short of editing both repositories, a backout is your only option
    • A backout allows you to make a new changeset which is the inverse of the original changeset, getting rid of the undesired changes without changing the history of the repository
    • A rollback is normally your best option if you haven't already pushed to a remote repo since it obliterates the changeset while leaving your working copy intact
    • Strip will get rid of a whole branch of changes, but like rollbacks it will only stay gone if you haven't pushed the changes anywhere else
    • The same goes for cloning a repository up to a prior revision - the other tools are easier anyway

提交回复
热议问题