Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How do i remove the "HEAD" branch from the branches list on the left side in SourceTree?

Jose Builes July 9, 2013

I've tried to right click on it... but there are different options than in other branches... how do I remove this one?

6 answers

1 accepted

2 votes
Answer accepted
KieranA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 17, 2013

Hi Jose,

Here's an extract from the docs:

set-head

Sets or deletes the default branch (i.e. the target of the symbolic-ref refs/remotes/<name>/HEAD) for the named remote. Having a default branch for a remote is not required, but allows the name of the remote to be specified in lieu of a specific branch. For example, if the default branch for origin is set to master, then origin may be specified wherever you would normally specify origin/master.

With -d, the symbolic ref refs/remotes/<name>/HEAD is deleted.

With -a, the remote is queried to determine its HEAD, then the symbolic-ref refs/remotes/<name>/HEAD is set to the same branch. e.g., if the remote HEAD is pointed at next, "git remote set-head origin -a" will set the symbolic-ref refs/remotes/origin/HEAD to refs/remotes/origin/next. This will only work if refs/remotes/origin/next already exists; if not it must be fetched first.

Use <branch> to set the symbolic-ref refs/remotes/<name>/HEAD explicitly. e.g., "git remote set-head origin master" will set the symbolic-ref refs/remotes/origin/HEAD to refs/remotes/origin/master. This will only work if refs/remotes/origin/master already exists; if not it must be fetched first.

I've made the command bold, and it's saying in the paragraph eariler that you use "-d" to delete that symbolic ref. So you're saying the remote ref HEAD should be deleted. However, in my local test case there is no remote branch HEAD so technically this command wouldn't work. It's a local branch here and not a remote one. This can be seen within SourceTree itself quite easily in the sidebar if you expand origin, so deleting the remote ref won't do anything.

So, if HEAD branch is only local then you'd need to use

git branch -D HEAD

...but please make sure you back your repository up first to make sure you're not losing any changes from this. Technically you shouldn't as it's only a branch pointer to the HEAD commit if you've checked something out, but as I say, it's not doing any harm being there.

Cheers

esionov September 2, 2014

git branch -D HEAD

works.

Sumit_Goswami June 1, 2018

@KieranA You are awsome dude.

4 votes
KieranA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 10, 2013

Hi Jose,

HEAD is a pointer to a commit (usually master) so when you checkout your repository the commit which HEAD points at will be checked out. Usually you'd want it if when checking out you want a different branch or tag to be checked out.

You can take a look at what it's pointing out by issuing the following command:

git branch -r

And you'll probably see something like the following:

origin/HEAD -&gt; origin/master

You can delete HEAD if you don't need it (although it doesn't do any harm being there) by issuing the following command:

git remote set-head origin -d

Hope that helps

2 votes
Tony Mann October 31, 2014

It would be nice if SourceTree has an option to hide origin/HEAD from the history. And I would have that option be on by default.

0 votes
Tony Mann October 31, 2014

Deleting origin/HEAD from the terminal worked great for me. So glad to not see it anymore.

0 votes
Jose Builes July 17, 2013

Thanks for your help I really appreciate it, but I'm afraid it didn't work... I opened Terminal from the icon next to the git flow icon on the top, and I entered: git remote set-head origin -d But apparently it didn't remove the branch (I did restart SourceTree)... am I doing something wrong?

0 votes
Jose Builes July 11, 2013
Thanks for your help I really appreciate it, but I'm afraid it didn't work... I opened Terminal from the icon next to the git flow icon on the top, and I entered: git remote set-head origin -d But apparently it didn't remove the branch (I did restart SourceTree)... am I doing something wrong?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events