user434509
user434509

Reputation: 435

How to rollback last n commits in mercurial

I have got a requirement where I need to rollback last 10 commits. How can I do it. Please help.

Upvotes: 1

Views: 254

Answers (2)

Tom
Tom

Reputation: 6739

If you haven't yet pushed, then you can use the Strip extension.

If you have pushed then It would be better to backout the commits.

Backing out a commit makes an additional commit of the exact opposite of the commit being removed, which gets appended to the repo. Hence you can still see the original commits in the repo history.

Upvotes: 3

Ismail Badawi
Ismail Badawi

Reputation: 37207

The easiest thing would be to clone the repo until the last commit you want to keep.

hg clone -r last_commit_to_keep myrepo mynewrepo

Upvotes: 4

Related Questions