# Deleting remote branches

6 messages from 2010-03-26 to 2010-03-26. Participants: jhapk, Ramkumar Ramachandra, Peter Baumann, Johannes Sixt, Chris Packham.
Thread: https://gitlist.dev/t/23181

## jhapk, 2010-03-26 05:46

Subject: Deleting remote branches
Message-ID: <1269582415273-4802262.post@n2.nabble.com>
URL: https://gitlist.dev/e/1269582415273-4802262.post%40n2.nabble.com

```

Hi,

I had a whole bunch of branches in my local and a remote repository. I
deleted all the redundant branches to be left with only three now. So the
result of $git branch on my local repository is
[pradeep@scaramanga cffc]$ git branch
  jeff
  master
* work
and on the remote directory which is called 'origin' it returns
[pradeep@scaramanga CFFC.git]$ git branch
  RANSmodel
* master
  work
But when I type the following command on my local branch, 
[pradeep@scaramanga cffc]$ git branch -a
  jeff
  master
* work
  origin/HEAD
  origin/RANSmodel
  origin/bluffbody
  origin/counterflow
  origin/flamelet
  origin/jeff
  origin/master
  origin/test
  origin/work
I still get all these branches which I deleted in my remote 'origin'.

My .git/config file looks like this
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        url = /nfs/carv/d1/people/pradeep/Repositories/CFFC.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[remote "jeff"]
        url = /nfs/kris/d1/people/jeff/cffc
        fetch = +refs/heads/pradeep:refs/remotes/jeff/pradeep
[branch "master"]
        remote = origin
        merge = refs/heads/master
[branch "work"]
        remote = origin
        merge = refs/heads/work
[push]
        default = matching
[branch "jeff"]
        remote = jeff
        merge = refs/heads/pradeep

Does anyone know why am I still getting branhces like origin/test when I do
$git branch -a
-- 
View this message in context: http://n2.nabble.com/Deleting-remote-branches-tp4802262p4802262.html
Sent from the git mailing list archive at Nabble.com.

```

## Ramkumar Ramachandra, 2010-03-26 06:00

Subject: Re: Deleting remote branches
Message-ID: <f3271551003252300u387f6081seaa03d4eb7194486@mail.gmail.com>
URL: https://gitlist.dev/e/f3271551003252300u387f6081seaa03d4eb7194486%40mail.gmail.com
In-Reply-To: <1269582415273-4802262.post@n2.nabble.com>

```
See `git push origin :branchname`. It's a listed example in git-push (1).

-- Ram

```

## jhapk, 2010-03-26 06:09

Subject: Re: Deleting remote branches
Message-ID: <1269583743012-4802313.post@n2.nabble.com>
URL: https://gitlist.dev/e/1269583743012-4802313.post%40n2.nabble.com
In-Reply-To: <f3271551003252300u387f6081seaa03d4eb7194486@mail.gmail.com>

```

Hi,

I have tried that and I get the following message

[pradeep@scaramanga cffc]$ git push origin:test
error: dst refspec test does not match any existing ref on the remote and
does not start with refs/.
fatal: The remote end hung up unexpectedly
error: failed to push to '/nfs/carv/d1/people/pradeep/Repositories/CFFC.git'

don't know what this means.
-- 
View this message in context: http://n2.nabble.com/Deleting-remote-branches-tp4802262p4802313.html
Sent from the git mailing list archive at Nabble.com.

```

## Peter Baumann, 2010-03-26 06:16

Subject: Re: Deleting remote branches
Message-ID: <20100326061652.GA28279@m62s10.vlinux.de>
URL: https://gitlist.dev/e/20100326061652.GA28279%40m62s10.vlinux.de
In-Reply-To: <1269583743012-4802313.post@n2.nabble.com>

```
On Thu, Mar 25, 2010 at 10:09:03PM -0800, jhapk wrote:
> 
> Hi,
> 
> I have tried that and I get the following message
> 
> [pradeep@scaramanga cffc]$ git push origin:test
                                      ^^^^^^^^^^^

Notice the missing space. From the git push manpage:

git push origin :experimental
               ^
    Find a ref that matches experimental in the origin repository (e.g.
    refs/heads/experimental), and delete it.


The syntax (with all the unused stuff removed) is 'git push <repository> <refspec>'
If you don't supply any repository (as you did with your cmdline), the default 
remote repository is used. Your command tried to push the local branch 'origin' into
the remote branch 'test' of your default remote repository. Correct would be

git push :test   # or git push origin :test

The refspec :test means push empy/nothingness into the branch 'test', which will delete it.

--
Peter

```

## Johannes Sixt, 2010-03-26 07:10

Subject: Re: Deleting remote branches
Message-ID: <4BAC5DD1.7050500@viscovery.net>
URL: https://gitlist.dev/e/4BAC5DD1.7050500%40viscovery.net
In-Reply-To: <1269582415273-4802262.post@n2.nabble.com>

```
Am 3/26/2010 6:46, schrieb jhapk:
> I had a whole bunch of branches in my local and a remote repository. I
> deleted all the redundant branches to be left with only three now.
...
> Does anyone know why am I still getting branhces like origin/test when I do
> $git branch -a

git remote prune origin

-- Hannes

```

## Chris Packham, 2010-03-26 15:52

Subject: Re: Deleting remote branches
Message-ID: <a038bef51003260852x204500fv8db7dd7a42516050@mail.gmail.com>
URL: https://gitlist.dev/e/a038bef51003260852x204500fv8db7dd7a42516050%40mail.gmail.com
In-Reply-To: <1269582415273-4802262.post@n2.nabble.com>

```
On Thu, Mar 25, 2010 at 10:46 PM, jhapk <pradeep.kumar.jha@gmail.com> wrote:
>
> Hi,
>
>  jeff
>  master
> * work
>  origin/HEAD
>  origin/RANSmodel
>  origin/bluffbody
>  origin/counterflow
>  origin/flamelet
>  origin/jeff
>  origin/master
>  origin/test
>  origin/work
> I still get all these branches which I deleted in my remote 'origin'.
>

'git remote prune origin' will clean up the references you have to
branches that no longer exist in origin

```
