views:

79

answers:

3

How can I undo the creation of a branch in Mercurial? For example, if I issue the command

hg branch newbranch

How can I delete this branch if I decide I entered the wrong name? I'm guessing this must be pretty simple to do, but I have yet to figure it out. Thanks!

+2  A: 

if you haven't committed anything to it, it wasn't really created. so just issue another hg branch newname.

Idan K
Hmm, it seems I have committed the branch then. Oops. That I can resolve. Thanks for a quick solution anyway! This is still helpful.
Michael Mior
in that case i don't think you can since the branch name is part of the revision. if it's that important you could `hg strip` the branch and do it all over again :)
Idan K
Boo! You shouldn't suggest `strip` without including a warning about the serious and severe risks in the case that other folks have already pulled the repo.
Ry4an
A: 

Assuming you have not pushed to a remote repository, enable the mq extension and strip the branch off.

Kyle Heironimus
A: 

If its already commited:

  • hg clone -b branch1 [-b branch2 [-b ..]] oldrepo newrepo, i.e. every branch except newbranch, will result in new repo without the newbranch.
  • If mq extension is enabled then hg strip

Look into editing history before making permanent changes in repository.

vsh