# remote tracking branch deletion problem

2 messages from 2008-12-19 to 2008-12-19. Participants: Thomas Jarosch, Michael J Gruber.
Thread: https://gitlist.dev/t/16797

## Thomas Jarosch, 2008-12-19 11:57

Subject: remote tracking branch deletion problem
Message-ID: <200812191257.18678.thomas.jarosch@intra2net.com>
URL: https://gitlist.dev/e/200812191257.18678.thomas.jarosch%40intra2net.com

```
Hello together,

while playing around with git, I stumbled upon a strange remote tracking 
branch deletion problem. It seems I'm unable to delete the remote tracking 
branch "origin/HEAD" using git 1.6.0.5. Here's what I did:

[tomj@storm repo]$ git init
Initialized empty Git repository in /tmp/repo/.git/

[tomj@storm repo]$ echo "test" >test
[tomj@storm repo]$ git add test
[tomj@storm repo]$ git commit -m "Test"

[tomj@storm tmp]$ git clone repo alice
Initialized empty Git repository in /tmp/alice/.git/

[tomj@storm alice]$ git branch -r
  origin/HEAD
  origin/master

[tomj@storm alice]$ git branch -r -d origin/HEAD
Deleted remote branch origin/HEAD.
[tomj@storm alice]$ git branch -r -d origin/master
Deleted remote branch origin/master.

[tomj@storm alice]$ ls -al .git/refs/remotes/origin/HEAD
-rw-rw---- 1 tomj intra2net 32 19. Dec 12:43 .git/refs/remotes/origin/HEAD
[tomj@storm alice]$ git branch -r
error: refs/remotes/origin/HEAD points nowhere!

Is this supposed to be? git 1.6.1.rc3.35.gc0ceb shows a similar behavior.

Cheers,
Thomas

```

## Michael J Gruber, 2008-12-19 14:56

Subject: Re: remote tracking branch deletion problem
Message-ID: <494BB637.3070304@drmicha.warpmail.net>
URL: https://gitlist.dev/e/494BB637.3070304%40drmicha.warpmail.net
In-Reply-To: <200812191257.18678.thomas.jarosch@intra2net.com>

```
Thomas Jarosch venit, vidit, dixit 19.12.2008 12:57:
> Hello together,
> 
> while playing around with git, I stumbled upon a strange remote tracking 
> branch deletion problem. It seems I'm unable to delete the remote tracking 
> branch "origin/HEAD" using git 1.6.0.5. Here's what I did:
> 
> [tomj@storm repo]$ git init
> Initialized empty Git repository in /tmp/repo/.git/
> 
> [tomj@storm repo]$ echo "test" >test
> [tomj@storm repo]$ git add test
> [tomj@storm repo]$ git commit -m "Test"
> 
> [tomj@storm tmp]$ git clone repo alice
> Initialized empty Git repository in /tmp/alice/.git/
> 
> [tomj@storm alice]$ git branch -r
>   origin/HEAD
>   origin/master
> 
> [tomj@storm alice]$ git branch -r -d origin/HEAD
> Deleted remote branch origin/HEAD.
> [tomj@storm alice]$ git branch -r -d origin/master
> Deleted remote branch origin/master.
> 
> [tomj@storm alice]$ ls -al .git/refs/remotes/origin/HEAD
> -rw-rw---- 1 tomj intra2net 32 19. Dec 12:43 .git/refs/remotes/origin/HEAD
> [tomj@storm alice]$ git branch -r
> error: refs/remotes/origin/HEAD points nowhere!
> 
> Is this supposed to be? git 1.6.1.rc3.35.gc0ceb shows a similar behavior.

I think the point here is that HEAD is really a symref. "git remote rm
origin" makes sure that symrefs are removed, and is the right command to
use here.

"git branch -r -d", as well as "git update-ref -d" fail to remove HEAD
because it's really not a branch but a symref.

You can use "git update-ref -d --no-deref" to remove HEAD.

Making builtin-branch use delete_ref(,,REF_ISSYMREF) leads to success
for your above commands. I don't know about side effects, though all
tests pass. Is this sensible?

I guess I should come up with a test for this along with the patch.

Michael

```
