How to delete a branch in bitbucket with mercurial hg?

16,222

Solution 1

Have you tried closing it? From hg help branch:

Use "hg commit --close-branch" to mark this branch as closed.

Solution 2

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."

Solution 3

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
Share:
16,222

Related videos on Youtube

Jurudocs
Author by

Jurudocs

Learing, learning, learning...

Updated on June 04, 2022

Comments

  • Jurudocs
    Jurudocs about 2 years

    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?