Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete a branch in bitbucket with mercurial hg?

I opened a second branch (branch2) locally in hg and pushed it to bitbucket. After that i merged the two branches locally and pushed it again...I have branch2 still living on bitbucket. How do i delete branch2 on bitbucket?

like image 833
Jurudocs Avatar asked Dec 06 '11 11:12

Jurudocs


People also ask

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 can I change branch in Mercurial?

From the main menu, select Hg | Mercurial | Update to. In the Switch Working Directory dialog that opens, specify the target working directory: To switch to another line of development, choose Branch and select the desired branch from the list.

How do I create a new branch in Hg 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.

What is Mercurial branch?

In Mercurial, branches refer to a linear line of consecutive changesets. Changesets (csets) refer to a complete set of changes made to a file in a repository.


3 Answers

Have you tried closing it? From hg help branch:

Use "hg commit --close-branch" to mark this branch as closed.
like image 50
Laurens Holst Avatar answered Nov 18 '22 01:11

Laurens Holst


Closing doesn't exactly delete a branch (remove all trace).

If you want to delete it, you need to hg strip it.

  1. In Bitbucket, find the revision where the branch was created, and go to Settings > Strip changesets > <Enter "Revision to strip">.
  2. Confirm the deletion of all the revisions attached to the revision you entered, then delete.

NOTE: This approach may not be so straight forward if you have merged. This approach is more for "I have created a branch incorrectly, I want to delete it, and recreate it again using the same branch name."

like image 24
sonjz Avatar answered Nov 18 '22 00:11

sonjz


Using hg workbench, I lookup up the commit that started the new branch, right clicked and selected ## Copy Hash.

Then I enabled the strip extension by adding the following to my mercurial.ini (located at %USERPROFILE%\mercurial.ini)

[extensions]
strip =

Finally I executed the strip command using the hash from my clipboard to remove the local branch:

hg strip 36012047aee7c08cdc4ede51293392c106a3d0b7
like image 28
Sam Avatar answered Nov 18 '22 00:11

Sam