# remotely deleting a branch

3 messages from 2009-06-01 to 2009-06-01. Participants: jean-luc malet, John Tapsell, Gustaf Hendeby.
Thread: https://gitlist.dev/t/19626

## jean-luc malet, 2009-06-01 10:16

Subject: remotely deleting a branch
Message-ID: <1de9d39c0906010316v657f2624i3f16b8b5bea73122@mail.gmail.com>
URL: https://gitlist.dev/e/1de9d39c0906010316v657f2624i3f16b8b5bea73122%40mail.gmail.com

```
hi!
I created a remote branch by doing
$ git push origin mynewbranch
I done some work on mynewbranch, commited, pushed changes to origin,
merged it to master and pushed to origin and deleted the mynewbranch
localy because I don't need it anymore
now I want to "undo" the git push origin mynewbranch ie remotely
delete the branch from the repository
I tried git push --mirror but it deleted all remote branches that I
didn't worked on... I don't want to have it be a mirror... but
something like
$ git branch -r -d origin/mynewbranch
$ git push
   ---> deleting origin/mynewbranch

how shall I do that?
thanks
JLM

-- 
KISS! (Keep It Simple, Stupid!)
(garde le simple, imbécile!)
"mais qu'est-ce que tu m'as pondu comme usine à gaz? fait des choses
simples et qui marchent, espèce d'imbécile!"
-----------------------------
"Si vous pensez que vous êtes trop petit pour changer quoique ce soit,
essayez donc de dormir avec un moustique dans votre chambre." Betty
Reese
http://www.grainesdechangement.com/citations.htm

```

## Gustaf Hendeby, 2009-06-01 10:59

Subject: Re: remotely deleting a branch
Message-ID: <4A23B481.6000302@isy.liu.se>
URL: https://gitlist.dev/e/4A23B481.6000302%40isy.liu.se
In-Reply-To: <4A23AE5A.4040804@isy.liu.se>

```
This should of course have been cc to the list too...

Gustaf Hendeby wrote:
> jean-luc malet wrote:
>> hi!
>> I created a remote branch by doing
>> $ git push origin mynewbranch
>> I done some work on mynewbranch, commited, pushed changes to origin,
>> merged it to master and pushed to origin and deleted the mynewbranch
>> localy because I don't need it anymore
>> now I want to "undo" the git push origin mynewbranch ie remotely
>> delete the branch from the repository
>> I tried git push --mirror but it deleted all remote branches that I
>> didn't worked on... I don't want to have it be a mirror... but
>> something like
>> $ git branch -r -d origin/mynewbranch
>> $ git push
>>    ---> deleting origin/mynewbranch
>>
>> how shall I do that?
>> thanks
>> JLM
>>
> 
> Hi Jean-Luc!
> 
> Have a look at the help for push, you will find
> 
>   git push origin :mynewbranch
> 
> to be what you are looking for.  It is listed quite far down as an example.
> 
> /Gustaf
> 

```

## John Tapsell, 2009-06-01 11:02

Subject: Re: remotely deleting a branch
Message-ID: <43d8ce650906010402t792df314v1ed632e79f42bca7@mail.gmail.com>
URL: https://gitlist.dev/e/43d8ce650906010402t792df314v1ed632e79f42bca7%40mail.gmail.com
In-Reply-To: <1de9d39c0906010316v657f2624i3f16b8b5bea73122@mail.gmail.com>

```
2009/6/1 jean-luc malet <jeanluc.malet@gmail.com>:
> hi!
> I created a remote branch by doing
> $ git push origin mynewbranch
> I done some work on mynewbranch, commited, pushed changes to origin,
> merged it to master and pushed to origin and deleted the mynewbranch
> localy because I don't need it anymore
> now I want to "undo" the git push origin mynewbranch ie remotely
> delete the branch from the repository
> I tried git push --mirror but it deleted all remote branches that I
> didn't worked on... I don't want to have it be a mirror... but
> something like
> $ git branch -r -d origin/mynewbranch
> $ git push
>   ---> deleting origin/mynewbranch
>
> how shall I do that?

Yeah, it's pretty confusing on how to delete a remote branch.  The
magic command is:

git push origin -f :mynewbranch

Hopefully someone will figure out a way to make git a bit more
intuitive in this respect.  Maybe a remote option for git branch -d or
something.
John

```
