# git push refspec problem

10 messages from 2007-11-07 to 2007-11-07. Participants: James, Johannes Schindelin, Pierre Habouzit, Johannes Gilger, Daniel Barkalow.
Thread: https://gitlist.dev/t/10704

## James, 2007-11-07 15:01

Subject: git push refspec problem
Message-ID: <7B37E361-9606-447C-B853-001182688AFA@nc.rr.com>
URL: https://gitlist.dev/e/7B37E361-9606-447C-B853-001182688AFA%40nc.rr.com

```
Hi,

I'm trying to set up my git configuration file in one of my projects  
so that I can do a simple "git push" to update my project on the git  
server.

Currently, I run the following command to push my updates (and it  
works just fine):

git push james@my.server.com:~/scm/git/project.git/

In my .git/config file, I've added a line for push, as follows:

[remote "origin"]
         url = git://my.server.com/project.git
         fetch = +refs/heads/*:refs/remotes/origin/*
         push = ssh://james@my.server.com/home/james/scm/git/ 
project.git/

When I run a "git push", it comes back with this error:

fatal: remote part of refspec is not a valid name in ssh://james@my.server.com/home/james/scm/git/project.git/

I've looked at this git push documentation:

http://www.kernel.org/pub/software/scm/git/docs/git-push.html

and it seems like my refspec is indeed correct.  (or so I thought ;))   
Any ideas on what I'm doing wrong?

Thanks!
.james

```

## Johannes Schindelin, 2007-11-07 15:11

Subject: Re: git push refspec problem
Message-ID: <Pine.LNX.4.64.0711071510480.4362@racer.site>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0711071510480.4362%40racer.site
In-Reply-To: <7B37E361-9606-447C-B853-001182688AFA@nc.rr.com>

```
Hi,

On Wed, 7 Nov 2007, James wrote:

>        fetch = +refs/heads/*:refs/remotes/origin/*

This is a refspec.

>        push = ssh://james@my.server.com/home/james/scm/git/project.git/

This is a URL.  It does not specify any refs.  But "push =" expects a URL.

You probably want to setup a different remote if you want to push to a 
different URL than you are fetching from.

Hth,
Dscho

```

## Pierre Habouzit, 2007-11-07 15:20

Subject: Re: git push refspec problem
Message-ID: <20071107152003.GL18057@artemis.corp>
URL: https://gitlist.dev/e/20071107152003.GL18057%40artemis.corp
In-Reply-To: <Pine.LNX.4.64.0711071510480.4362@racer.site>

```
On Wed, Nov 07, 2007 at 03:11:46PM +0000, Johannes Schindelin wrote:
> Hi,
> 
> On Wed, 7 Nov 2007, James wrote:
> 
> >        fetch = +refs/heads/*:refs/remotes/origin/*
> 
> This is a refspec.
> 
> >        push = ssh://james@my.server.com/home/james/scm/git/project.git/
> 
> This is a URL.  It does not specify any refs.  But "push =" expects a URL.
> 
> You probably want to setup a different remote if you want to push to a 
> different URL than you are fetching from.

  Oh, there is no way to pull through git:// and push to ssh://
perfectly knowint it's the same physical repository so that the fetch
doesn't have the ssh-handhshake-overhead ?


-- 
·O·  Pierre Habouzit
··O                                                madcoder@debian.org
OOO                                                http://www.madism.org

```

## Johannes Gilger, 2007-11-07 15:22

Subject: Re: git push refspec problem
Message-ID: <4731D852.2080500@hackvalue.de>
URL: https://gitlist.dev/e/4731D852.2080500%40hackvalue.de
In-Reply-To: <Pine.LNX.4.64.0711071510480.4362@racer.site>

```
Johannes Schindelin wrote:
> Hi,
> 
> On Wed, 7 Nov 2007, James wrote:
> 
>>        fetch = +refs/heads/*:refs/remotes/origin/*
> 
> This is a refspec.
> 
>>        push = ssh://james@my.server.com/home/james/scm/git/project.git/
> 
> This is a URL.  It does not specify any refs.  But "push =" expects a URL.

I think Johannes meant to say "But 'push =' expects a refspec." (the
manpage even says so).

About your problem: If you want to pull from a git:// repository and
push to another with ssh:// (or in general when having two different
repositories for pushing and fetching) in my novice understanding
you would need two remotes. In your case, can't you just use your
ssh-url for fetching as well?

Regards,
Jojo

-- 
Johannes Gilger <heipei@hackvalue.de>
http://hackvalue.de/heipei/
GPG-Key: 0x42F6DE81
GPG-Fingerprint: BB49 F967 775E BB52 3A81  882C 58EE B178 42F6 DE81

```

## James, 2007-11-07 15:23

Subject: Re: git push refspec problem
Message-ID: <EA230407-45F1-4F7E-8415-A43ECF940856@nc.rr.com>
URL: https://gitlist.dev/e/EA230407-45F1-4F7E-8415-A43ECF940856%40nc.rr.com
In-Reply-To: <20071107152003.GL18057@artemis.corp>

```
On Nov 7, 2007, at 10:20 AM, Pierre Habouzit wrote:

> On Wed, Nov 07, 2007 at 03:11:46PM +0000, Johannes Schindelin wrote:
>> Hi,
>>
>> On Wed, 7 Nov 2007, James wrote:
>>
>>>       fetch = +refs/heads/*:refs/remotes/origin/*
>>
>> This is a refspec.
>>
>>>       push = ssh://james@my.server.com/home/james/scm/git/project.git/
>>
>> This is a URL.  It does not specify any refs.  But "push =" expects  
>> a URL.
>>
>> You probably want to setup a different remote if you want to push  
>> to a
>> different URL than you are fetching from.
>
>  Oh, there is no way to pull through git:// and push to ssh://
> perfectly knowint it's the same physical repository so that the fetch
> doesn't have the ssh-handhshake-overhead ?


There has to be *some* way of pulling through git and pushing through  
ssh with a simple "git push".  :-P  I'm doing it manually, after all.   
I could have sworn I've read how to do its somewhere but have since  
forgotten.


> -- 
> ·O·  Pierre Habouzit
> ··O                                                madcoder@debian.org
> OOO                                                http://www.madism.org

```

## Johannes Gilger, 2007-11-07 15:26

Subject: Re: git push refspec problem
Message-ID: <4731D918.6040106@hackvalue.de>
URL: https://gitlist.dev/e/4731D918.6040106%40hackvalue.de
In-Reply-To: <EA230407-45F1-4F7E-8415-A43ECF940856@nc.rr.com>

```
James wrote:
> There has to be *some* way of pulling through git and pushing through
> ssh with a simple "git push".  :-P  I'm doing it manually, after all.  I
> could have sworn I've read how to do its somewhere but have since
> forgotten.

Would two remotes do the trick? One remote only has a fetch entry
while the other one has a push entry.

Regards,
Jojo

-- 
Johannes Gilger <heipei@hackvalue.de>
http://hackvalue.de/heipei/
GPG-Key: 0x42F6DE81
GPG-Fingerprint: BB49 F967 775E BB52 3A81  882C 58EE B178 42F6 DE81

```

## James, 2007-11-07 15:30

Subject: Re: git push refspec problem
Message-ID: <607586B5-7BA0-4018-9FB1-691C5E78D550@nc.rr.com>
URL: https://gitlist.dev/e/607586B5-7BA0-4018-9FB1-691C5E78D550%40nc.rr.com
In-Reply-To: <4731D852.2080500@hackvalue.de>

```

On Nov 7, 2007, at 10:22 AM, Johannes Gilger wrote:

> Johannes Schindelin wrote:
>> Hi,
>>
>> On Wed, 7 Nov 2007, James wrote:
>>
>>>       fetch = +refs/heads/*:refs/remotes/origin/*
>>
>> This is a refspec.
>>
>>>       push = ssh://james@my.server.com/home/james/scm/git/project.git/
>>
>> This is a URL.  It does not specify any refs.  But "push =" expects  
>> a URL.
>
> I think Johannes meant to say "But 'push =' expects a refspec." (the
> manpage even says so).
>
> About your problem: If you want to pull from a git:// repository and
> push to another with ssh:// (or in general when having two different
> repositories for pushing and fetching) in my novice understanding
> you would need two remotes. In your case, can't you just use your
> ssh-url for fetching as well?
>
> Regards,
> Jojo


I guess I could use my ssh url for pulling, as well.  I simply figured  
it would be easier to add an ssh URL for push (like I was doing  
manually) and be done with it.  But it doesn't seem there's a super  
simple solution (i.e., my syntax was wrong in the config file) to  
using git for pull and ssh for push.

.james


> -- 
> Johannes Gilger <heipei@hackvalue.de>
> http://hackvalue.de/heipei/
> GPG-Key: 0x42F6DE81
> GPG-Fingerprint: BB49 F967 775E BB52 3A81  882C 58EE B178 42F6 DE81

```

## Pierre Habouzit, 2007-11-07 15:38

Subject: Re: git push refspec problem
Message-ID: <20071107153852.GM18057@artemis.corp>
URL: https://gitlist.dev/e/20071107153852.GM18057%40artemis.corp
In-Reply-To: <4731D918.6040106@hackvalue.de>

```
On Wed, Nov 07, 2007 at 03:26:16PM +0000, Johannes Gilger wrote:
> James wrote:
> > There has to be *some* way of pulling through git and pushing through
> > ssh with a simple "git push".  :-P  I'm doing it manually, after all.  I
> > could have sworn I've read how to do its somewhere but have since
> > forgotten.
> 
> Would two remotes do the trick? One remote only has a fetch entry
> while the other one has a push entry.

  Yes you can do that, but that means you have to spell out the remote
name either for fetching or pushing which somehow sucks :)


-- 
·O·  Pierre Habouzit
··O                                                madcoder@debian.org
OOO                                                http://www.madism.org

```

## Johannes Schindelin, 2007-11-07 15:39

Subject: Re: git push refspec problem
Message-ID: <Pine.LNX.4.64.0711071539100.4362@racer.site>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0711071539100.4362%40racer.site
In-Reply-To: <4731D852.2080500@hackvalue.de>

```
Hi,

On Wed, 7 Nov 2007, Johannes Gilger wrote:

> Johannes Schindelin wrote:
> 
> > On Wed, 7 Nov 2007, James wrote:
> > 
> >>        fetch = +refs/heads/*:refs/remotes/origin/*
> > 
> > This is a refspec.
> > 
> >>        push = ssh://james@my.server.com/home/james/scm/git/project.git/
> > 
> > This is a URL.  It does not specify any refs.  But "push =" expects a 
> > URL.
> 
> I think Johannes meant to say "But 'push =' expects a refspec." (the 
> manpage even says so).

Of course.  Thanks.

Ciao,
Dscho

```

## Daniel Barkalow, 2007-11-07 20:40

Subject: Re: git push refspec problem
Message-ID: <Pine.LNX.4.64.0711071533590.29952@iabervon.org>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0711071533590.29952%40iabervon.org
In-Reply-To: <607586B5-7BA0-4018-9FB1-691C5E78D550@nc.rr.com>

```
On Wed, 7 Nov 2007, James wrote:

> On Nov 7, 2007, at 10:22 AM, Johannes Gilger wrote:
> 
> >Johannes Schindelin wrote:
> > >Hi,
> > >
> > >On Wed, 7 Nov 2007, James wrote:
> > >
> > > >      fetch = +refs/heads/*:refs/remotes/origin/*
> > >
> > >This is a refspec.
> > >
> > > >      push = ssh://james@my.server.com/home/james/scm/git/project.git/
> > >
> > >This is a URL.  It does not specify any refs.  But "push =" expects a URL.
> >
> >I think Johannes meant to say "But 'push =' expects a refspec." (the
> >manpage even says so).
> >
> >About your problem: If you want to pull from a git:// repository and
> >push to another with ssh:// (or in general when having two different
> >repositories for pushing and fetching) in my novice understanding
> >you would need two remotes. In your case, can't you just use your
> >ssh-url for fetching as well?
> >
> >Regards,
> >Jojo
> 
> 
> I guess I could use my ssh url for pulling, as well.  I simply figured it
> would be easier to add an ssh URL for push (like I was doing manually) and be
> done with it.  But it doesn't seem there's a super simple solution (i.e., my
> syntax was wrong in the config file) to using git for pull and ssh for push.

We *should* be able to make the rules: fetch tries URLs until one works, 
and then ignores later ones; push uses, in turn, all URLs that support 
pushing.

Then you could just list both URLs, with the "git:" one first, and it 
would do what you want (plus, if the git server on your remote machine 
were down, it would fall back to ssh automatically for you).

Actually, I think this would be a relatively easy project now, if you want 
to attempt it, since fetch and push and both in C now and the config file 
parser in remote.h reports all URLs in the config file's order. You'd just 
need to make it silently skip URLs in push that don't support pushing, and 
only give an error if none remain. (And add fallback support to fetch, for 
completeness; it's currently only using the first, IIRC).

	-Daniel
*This .sig left intentionally blank*

```
