How can I hide Mercurial closed branches in SourceTree?
Asked by Shawn South:

When I close a branch it disappears from the sidebar, but still shows up in the graph. How can I remove my closed branches from the graph? I know I can view just the *current* branch, but that's not what I want. I'd like to be able to see all open branches without old, closed ones cluttering up the graph.


Answers:
author: Mikhail Belov
body: This is pretty old thread as I see, but is there a solution? I've just updated SourceTree from version 1.7 to 2.1.2.4 and it shows every branch ever made. How it can be solved? Except the downgrading back to 1.7, the most stable one?

comments: author: dcholth
body: Same issue in 2.1.2.5. Just appeared after updating.


author: Mikhail Belov
body: I've downgraded to 2.0.20.1. It does not have this bug.


author: dcholth
body: Its a bug introduced in the latest releases. Look up their ticket SRCTREEWIN-7189 and upvote it.


author: timothyp
body: Same here


author: VSquash
body: Also have this problem on Windows. Voted in the SRCTREEWIN-7189 ticket: <https://jira.atlassian.com/browse/SRCTREEWIN-7189>

So everytone, please vote in this ticket too. Hope this bug will be fixed soon.


author: piedenis
body: I've the same need as Shawn. I've about 50 closed branches (Mercurial) that I want to be got rid of. Could someone answer, please?


author: Johannes Kilian
body: "Closing a branch" is not primary a terminology from git itself but rather from branch workflows like gitflow (I assume you are using gitflow within sourcetree,,,).

A branch in git is simply a lightweight movable pointer on a commit - nothing else. The gitflow-term "closing a branch" consists of two elementary git-steps: 1.) merging the commits (to which the branch pointer currently points to - and previously has been pointing to) into another commit and 2.) removing the pointer. After "closing the branch" the commits (on the "deleted" branch) still exist (they HAVE to exist as hey are part of your commit history - and you surely don't want git to remove anything of your commit history ...) - and only thepointer is removed. That's what you see when looking on the graph.

*** ** * ** ***

see:

* <http://stackoverflow.com/questions/8614112/how-to-close-off-a-git-branch>
* <http://git-scm.com/book/en/v1/Git-Branching-What-a-Branch-Is>

*** ** * ** ***

If you want to cleanup your commit history when merging a branch you have to use more advanced commands like a "squash merge" (on merge all commits of the branch are summarized into one single commit - and this single commit is incorporated into your destination branch (i.e the commit to which the pointer with your destination branchname points to) - all the commits on your branch are removed). Another git command to rewrite your commit history is git rebase.

*** ** * ** ***

see:

* <http://git-scm.com/book/it/v2/Git-Tools-Rewriting-History>
* <https://robots.thoughtbot.com/git-interactive-rebase-squash-amend-rewriting-history>

*** ** * ** ***

Be aware that those advanced git concepts are rewritng your commit history - which is always a **bad idea if you have previously pushed the commits** ... (you have to perform a "forced push" then - which is considered as evil by many people (<http://willi.am/blog/2014/08/12/the-dark-side-of-the-force-push/>)

**SUMMARY:** "Closing a branch" does not change your commit history - that's what you currently complain about and what you see in your graph.The branch pointer is simply removed - therefore you don't see it anymore in the sourcetree sidebar - and your commits are merged. If you want to modify the commit history, you have to use more advanced git commands - and be aware of potential risks when rewriting an already pushed commit history!!!

comments: author: Shawn South
body: Thanks for the detailed answer, but my question is in regards to Mercurial (which does have a "close branch)" function), not Git.


author: Johannes Kilian
body: No idea about mercurial - sry. Should have read your question better ... ;-)


Tags: mercurial