It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Why only "Close" a branch instead of "Delete" it?

Ben Tatham Apr 06, 2014

On the pull request page, you can chose to "Close" a branch after it is merged.

Why would you want to close it rather than just delete it?

From what I can tell, close is just a bitbucket idea that hides the branch in the main list of pull-requests/branches, but it will still appear in regular git views/source tree lists of branches. Is there some idea of close that git itself knows about it (that I am unfamiliar with)?

Note we often merge branches into develop locally either in SourceTree (with GitFlow button) or using jgitflow-maven-plugin, which deletes the branch locally but not on origin (bitbucket) - although I wish those tools would.

2 answers

1 accepted

11 votes
Answer accepted
Ben Tatham Jun 15, 2014

It seems that I was mistaken. Marking a pull request to Close branch when merged, does indeed Delete it. I'm not sure why they use different language for that though.

0 votes

Hi Ben,

I’ve tried to reproduce this behaviour without success on SourceTree connecting to Bitbucket:

  1. Added a repository from Bitbucket.
  2. Initialised Git flow.
  3. Created a new feature branch with Git flow.
  4. Made a commit on that feature branch.
  5. Pushed all to Bitbucket
  6. Hit "Finish feature" with the "Delete branch" option selected.
  7. Merge happened and the feature branch was deleted.

If it’s not the steps that you are following, could you please let me know which steps are you following? Then I can further help you on it.

There is also the option to delete a branch using the git application through this command:

git push origin --delete <branchName>

Kind Regards,

Henrique Lechner

Seth Jun 08, 2014

I see the same behavior as Ben in regards to Git Flow. The feature branch gets deleted locally but not on my remotes. I am aware of the command line method, and you can also delete remote branches from the remote's branch list, but both are less convenient.

In any case, Ben's question is actually about Bitbucket closing a branch following a pull request. Any helpful information there?

Daniel Flores Mar 18, 2016

2016 here, still seeing this issue.  Using BitBucket, after merging a PR it doesn't delete the branch if Close branch when merged is selected when clicking merge.

Dale Cook Mar 29, 2016

I too see the same results as the others when selecting "Close branch" on the pull request.  After it is merged it is just moved to the "merged" list in Bitbucket.  But in your own tool SourceTree and all other Git GUI's or TUI's the branch is still there.  So why not just delete the branch as one would assume when you "Close" the branch or provide a option to delete the branch when closing or something like that. 

If you do not provide this then we just have to go and do it manually which should not be necessary.  Is there an Add-in to provide this functionality?  We just want help...  Please

At the very least, a good explanation of why Bitbucket does not delete the branch?  What is the benefit to us the end user? 

Nicole Zajork Apr 08, 2016

This explains the problem we were seeing: 

https://github.com/gitextensions/gitextensions/issues/2141

http://kb.detlus.com/articles/git/how-to-update-remote-branch-list-on-local-machine/

In Git Extensions, I just used "Prune Remote Branches" which would remove any remote branches on my local machine that do not exist remotely anymore.

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Bitbucket Pipelines

Building a Bitbucket Pipe as a casual coder

...ipe.sh :  #!/bin/bash source "$(dirname "$0")/common.sh" enable_debug extra_args="" if [[ "${DEBUG}" == "true" ]]; then extra_args="--verbose" fi # mandatory variables R...

3,067 views 1 20
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you