threads / discuss / 10704

git push refspec problem

Subject: git push refspec problem

## tl;dr

10 messages between Nov 7, 2007 and Nov 7, 2007.

replies: 9people: 5as markdown or json

James· Nov 7, 2007, 15:01 UTC · lore
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· Nov 7, 2007, 15:11 UTC · re: James · lore

Re: git push refspec problem

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· Nov 7, 2007, 15:20 UTC · re: Johannes Schindelin · lore

Re: git push refspec problem

On Wed, Nov 07, 2007 at 03:11:46PM +0000, Johannes Schindelin wrote:
Show 14 quoted lines
> 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
James· Nov 7, 2007, 15:23 UTC · re: Pierre Habouzit · lore

Re: git push refspec problem

On Nov 7, 2007, at 10:20 AM, Pierre Habouzit wrote:
Show 21 quoted lines
> 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· Nov 7, 2007, 15:26 UTC · re: James · lore

Re: git push refspec problem

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
Pierre Habouzit· Nov 7, 2007, 15:38 UTC · re: Johannes Gilger · lore

Re: git push refspec problem

On Wed, Nov 07, 2007 at 03:26:16PM +0000, Johannes Gilger wrote:
Show 8 quoted lines
> 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 Gilger· Nov 7, 2007, 15:22 UTC · re: Johannes Schindelin · lore

Re: git push refspec problem

Johannes Schindelin wrote:
Show 11 quoted lines
> 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· Nov 7, 2007, 15:30 UTC · re: Johannes Gilger · lore

Re: git push refspec problem

On Nov 7, 2007, at 10:22 AM, Johannes Gilger wrote:
Show 25 quoted lines
> 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
Show 5 quoted lines
> -- 
> Johannes Gilger <heipei@hackvalue.de>
> http://hackvalue.de/heipei/
> GPG-Key: 0x42F6DE81
> GPG-Fingerprint: BB49 F967 775E BB52 3A81  882C 58EE B178 42F6 DE81
Daniel Barkalow· Nov 7, 2007, 20:40 UTC · re: James · lore

Re: git push refspec problem

On Wed, 7 Nov 2007, James wrote:
Show 32 quoted lines
> 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*
Johannes Schindelin· Nov 7, 2007, 15:39 UTC · re: Johannes Gilger · lore

Re: git push refspec problem

Hi,
On Wed, 7 Nov 2007, Johannes Gilger wrote:
Show 15 quoted lines
> 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

← back to recent threads