开发者

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 wron开发者_运维知识库g name? I'm guessing this must be pretty simple to do, but I have yet to figure it out. Thanks!


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.


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


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜