Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undoing branch creation in Mercurial

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!

like image 426
Michael Mior Avatar asked Jun 07 '10 18:06

Michael Mior


People also ask

How do you undo a pull in mercurial?

There is only one level of rollback, and there is no way to undo a rollback. It will also restore the dirstate at the time of the last transaction, losing any dirstate changes since that time. This command does not alter the working directory.

How do I delete a branch in Mercurial?

You cannot. You can close the branch to hide it from the list of active branches, but you cannot completely delete it. This happens because in mercurial and in git the "branch" term means different things. In mercurial - it is a set of changesets.

How do I revert my hg add?

hg revert -r . ^ path-to-file will revert the commit from the commit-set. then commit and submit (if using jelly fish) and you'll see the files removed from the changeset.

How do I create a branch in Mercurial?

Creating a branch Branching can happen by committing a changeset within a single repository or by committing diverging changes in distinct (but related) repositories. Two repositories are said to be related if they were once cloned from the same repository but later may have diverged.


1 Answers

If you haven't committed yet, you can simply do a clean reset as per the manual (http://www.selenic.com/mercurial/hg.1.html#commands):

hg branch -C 

This will reset the working directory's branch name to the parent of the branch that you just created.

like image 130
JavaSplice Avatar answered Oct 20 '22 01:10

JavaSplice