Discard a local branch in Mercurial before it is pushed

If you find yourself doing this often perhaps you should be using bookmarks instead of named branches. http://stevelosh.com/blog/2009/08/a-guide-to-branching-in-mercurial/


I know its too late but it may be useful for any one:

If your branch is not pushed yet.

  • First rollback changes hg rollback only if you have done commit but not yet pushed
  • Second run hg update --clean
  • Third run hg branch any-existing-branch
  • Fourth run hg pull -u

If you enable the mq extension (bundled with Mercurial), you can use hg strip. Be careful, though, as this will modify the history of your repository. The safe method is to clone your repository up to the revision preceding the creation of the branch you want to discard, then to pull the remaining changesets that you want to keep.