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

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

Jose Builes Jul 09, 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

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

Edward Sionov Sep 02, 2014

git branch -D HEAD

works.

Sumit Goswami Jun 01, 2018

@Kieran Senior [ You are awsome dude.

2 votes

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

1 vote
Tony Mann Oct 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
Jose Builes Jul 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?
0 votes
Jose Builes Jul 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
Tony Mann Oct 31, 2014

Deleting origin/HEAD from the terminal worked great for me. So glad to not see it 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...

1,652 views 1 18
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