tags:

views:

58

answers:

2

I comitted few times with mercurial and pushed my commits. Nobody else pulled them. How can I "throw away" these commits to restore my local and remote repo (both repo and working dir) to a specified commit? Thank you.

+2  A: 

The quickest way is to just clone your local repo to the last 'good' revision, and discard the old one.

This only works if those revisions are the last n in the history.

You can copy the [paths] section of the old repo's .hg/hgrc file to the new one if you want to continue pushing to a third 'master' repo.

John Weldon
A: 

You can use $hg revert to revert your code to a previous revision.

If you type $hg help revert into your command line you'll get a list of ways you can revert.

These options include:

--all

--date

--rev

--rev will likely be the one you want since it reverts back to a specific revision.

If the revision you want to revert to is the same as another repo or the same as the current tip, the easiest way then could be to just re-clone that repo.

Jamie Dixon
hg revert only changes the working directory. It does not affect the history of the repository, even with --rev. In fact, hg revert --rev REV is identical to hg up -C REV.
tghw
Thanks for the heads up @tghw. I learn something new every day :)
Jamie Dixon