# pushing remote branches

6 messages from 2009-11-14 to 2009-11-16. Participants: Lorenzo Bettini, Sitaram Chamarty, Junio C Hamano.
Thread: https://gitlist.dev/t/21621

## Lorenzo Bettini, 2009-11-14 23:37

Subject: pushing remote branches
Message-ID: <hdneuv$nc8$2@ger.gmane.org>
URL: https://gitlist.dev/e/hdneuv%24nc8%242%40ger.gmane.org

```
Hi

I recently started to use git, and I experienced problems with branches: 
on my machine I did (on an already cloned repo)

git checkout -b experiments origin/experiments

and thus my config reads

[remote "origin"]
         fetch = +refs/heads/*:refs/remotes/origin/*
         url = git://...
[branch "master"]
         remote = origin
         merge = refs/heads/master
[branch "experiments"]
         remote = origin
         merge = refs/heads/experiments

isn't this enough to be able to push the experiments branch?

I tried

git push origin experiments

It tells me that it is a read-only url...

after adding

[remote "experiments"]
         url = git@...
         fetch = 
+refs/heads/experiments:refs/remotes/experiments/experiments

I can now push that branch with

git push experiments experiments

but I was wondering whether the initial config wasn't enough...

many thanks in advance
	Lorenzo

-- 
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134     (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com  http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net

```

## Sitaram Chamarty, 2009-11-15 00:45

Subject: Re: pushing remote branches
Message-ID: <2e24e5b90911141645n59680856ja21f2f3c7063f7c0@mail.gmail.com>
URL: https://gitlist.dev/e/2e24e5b90911141645n59680856ja21f2f3c7063f7c0%40mail.gmail.com
In-Reply-To: <hdneuv$nc8$2@ger.gmane.org>

```
Hi Lorenzo,

On Sun, Nov 15, 2009 at 5:07 AM, Lorenzo Bettini <bettini@dsi.unifi.it> wrote:

>            url = git://...

> isn't this enough to be able to push the experiments branch?

not normally.

The "git://" protocol is a read-only protocol by default.  Since it is
completely unauthenticated, enabling push via git:// is not a good idea in
general.

>            url = git@...

This is a shortcut for something like ssh://git@..., which then allows write
also.

```

## Lorenzo Bettini, 2009-11-15 10:21

Subject: Re: pushing remote branches
Message-ID: <hdoko1$s78$1@ger.gmane.org>
URL: https://gitlist.dev/e/hdoko1%24s78%241%40ger.gmane.org
In-Reply-To: <2e24e5b90911141645n59680856ja21f2f3c7063f7c0@mail.gmail.com>

```
Sitaram Chamarty wrote:
> Hi Lorenzo,
> 
> On Sun, Nov 15, 2009 at 5:07 AM, Lorenzo Bettini <bettini@dsi.unifi.it> wrote:
> 
>>            url = git://...
> 
>> isn't this enough to be able to push the experiments branch?
> 
> not normally.
> 
> The "git://" protocol is a read-only protocol by default.  Since it is
> completely unauthenticated, enabling push via git:// is not a good idea in
> general.

so probably I managed to push origin master anyway because gitorious 
asked me for my ssh passphrase?

> 
>>            url = git@...
> 
> This is a shortcut for something like ssh://git@..., which then allows write
> also.

Thus, if I had

[remote "origin"]
         fetch = +refs/heads/*:refs/remotes/origin/*
         url = git@...
[branch "master"]
         remote = origin
         merge = refs/heads/master
[branch "experiments"]
         remote = origin
         merge = refs/heads/experiments

instead of

[remote "origin"]
         fetch = +refs/heads/*:refs/remotes/origin/*
         url = git://...
[branch "master"]
         remote = origin
         merge = refs/heads/master
[branch "experiments"]
         remote = origin
         merge = refs/heads/experiments

I would have been able to push also to branch experiments?  Without 
having to add

[remote "experiments"]
         url = git@...
         fetch = 
+refs/heads/experiments:refs/remotes/experiments/experiments

?

thanks in advance
	Lorenzo

-- 
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134     (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com  http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net

```

## Sitaram Chamarty, 2009-11-15 11:04

Subject: Re: pushing remote branches
Message-ID: <2e24e5b90911150304i1472ed13k6c60611ef2e9ba19@mail.gmail.com>
URL: https://gitlist.dev/e/2e24e5b90911150304i1472ed13k6c60611ef2e9ba19%40mail.gmail.com
In-Reply-To: <hdoko1$s78$1@ger.gmane.org>

```
On Sun, Nov 15, 2009 at 3:51 PM, Lorenzo Bettini <bettini@dsi.unifi.it> wrote:
> Sitaram Chamarty wrote:
>>
>> Hi Lorenzo,
>>
>> On Sun, Nov 15, 2009 at 5:07 AM, Lorenzo Bettini <bettini@dsi.unifi.it>
>> wrote:
>>
>>>                url = git://...
>>
>>> isn't this enough to be able to push the experiments branch?
>>
>> not normally.
>>
>> The "git://" protocol is a read-only protocol by default.   Since it is
>> completely unauthenticated, enabling push via git:// is not a good idea in
>> general.
>
> so probably I managed to push origin master anyway because gitorious asked
> me for my ssh passphrase?

As far as I know you could not have pushed anything when the url is
git:// (at least by default.  Push over git:// can be enabled but is
highly inadvisable and I have not seen anyone enable it nor any good
reason to)

> Thus, if I had
>
> [remote "origin"]
>            fetch = +refs/heads/*:refs/remotes/origin/*
>            url = git@...
> [branch "master"]
>            remote = origin
>            merge = refs/heads/master
> [branch "experiments"]
>            remote = origin
>            merge = refs/heads/experiments
>
> instead of
>
> [remote "origin"]
>            fetch = +refs/heads/*:refs/remotes/origin/*
>            url = git://...
> [branch "master"]
>            remote = origin
>            merge = refs/heads/master
> [branch "experiments"]
>            remote = origin
>            merge = refs/heads/experiments
>
> I would have been able to push also to branch experiments?   Without having
> to add
>
> [remote "experiments"]
>            url = git@...
>            fetch = +refs/heads/experiments:refs/remotes/experiments/experiments
>
> ?

(by the way: do you mean refs/remotes/origin/experiments in that last
line above?)

Anyway to answer your question, I do not see the refspec line as the issue
here, but the URL for the repo, which determines how you access it.

regards,

sitaram

```

## Lorenzo Bettini, 2009-11-16 15:27

Subject: Re: pushing remote branches
Message-ID: <hdrr1e$oub$1@ger.gmane.org>
URL: https://gitlist.dev/e/hdrr1e%24oub%241%40ger.gmane.org
In-Reply-To: <2e24e5b90911150304i1472ed13k6c60611ef2e9ba19@mail.gmail.com>

```
Sitaram Chamarty wrote:
> 
>> Thus, if I had
>>
>> [remote "origin"]
>>            fetch = +refs/heads/*:refs/remotes/origin/*
>>            url = git@...
>> [branch "master"]
>>            remote = origin
>>            merge = refs/heads/master
>> [branch "experiments"]
>>            remote = origin
>>            merge = refs/heads/experiments
>>
>> instead of
>>
>> [remote "origin"]
>>            fetch = +refs/heads/*:refs/remotes/origin/*
>>            url = git://...
>> [branch "master"]
>>            remote = origin
>>            merge = refs/heads/master
>> [branch "experiments"]
>>            remote = origin
>>            merge = refs/heads/experiments
>>
>> I would have been able to push also to branch experiments?   Without having
>> to add
>>
>> [remote "experiments"]
>>            url = git@...
>>            fetch = +refs/heads/experiments:refs/remotes/experiments/experiments
>>
>> ?
> 
> (by the way: do you mean refs/remotes/origin/experiments in that last
> line above?)
> 

no, it's just like I wrote it...

you mean in

[remote "experiments"]
         url = git@gitorious.org...
         fetch = 
+refs/heads/experiments:refs/remotes/experiments/experiments

or in

[branch "experiments"]
         remote = origin
         merge = refs/heads/experiments


?

> Anyway to answer your question, I do not see the refspec line as the issue
> here, but the URL for the repo, which determines how you access it.

so this would have been enough:

 >> [remote "origin"]
 >>            fetch = +refs/heads/*:refs/remotes/origin/*
 >>            url = git://...
 >> [branch "master"]
 >>            remote = origin
 >>            merge = refs/heads/master
 >> [branch "experiments"]
 >>            remote = origin
 >>            merge = refs/heads/experiments

?

thanks
	Lorenzo

-- 
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
BLOGS: http://tronprog.blogspot.com  http://longlivemusic.blogspot.com

```

## Junio C Hamano, 2009-11-16 20:05

Subject: Re: pushing remote branches
Message-ID: <7vlji6p75y.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vlji6p75y.fsf%40alter.siamese.dyndns.org
In-Reply-To: <hdrr1e$oub$1@ger.gmane.org>

```
Lorenzo Bettini <bettini@dsi.unifi.it> writes:

>> Anyway to answer your question, I do not see the refspec line as the issue
>> here, but the URL for the repo, which determines how you access it.
>
> so this would have been enough:
>
>>> [remote "origin"]
>>>            fetch = +refs/heads/*:refs/remotes/origin/*
>>>            url = git://...
>>> [branch "master"]
>>>            remote = origin
>>>            merge = refs/heads/master
>>> [branch "experiments"]
>>>            remote = origin
>>>            merge = refs/heads/experiments

Because "git://" is almost always read-only, you wouldn't be able to push
back to the origin with that configuration.  If you are only following the
project that is perfectly fine.

Otherwise, either use "git@..." in remote.origin.url to use git-over-ssh
in both directions, or you can use pushurl if you have recent enough
version of git, like:

    [remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = git://...
        pushurl = git@...

When you primed your repository with "git clone git://...", it would be
nice if "clone" added a "corresponding" pushurl for you.  But ... part of
the two lines are often different, depending on how hosting site is
organized, so unfortunately "clone" cannot do so.

```
