git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git push refspec problem

From
Daniel Barkalow <barkalow@iabervon.org>
Date
Nov 7, 2007, 20:40 UTC
Message-ID
<Pine.LNX.4.64.0711071533590.29952@iabervon.org>
In-Reply-To
<607586B5-7BA0-4018-9FB1-691C5E78D550@nc.rr.com>
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*
Previous: JamesNext: Johannes Schindelin
Message 9 of 10 in “git push refspec problem”
  1. JamesNov 7, 2007
  2. Johannes SchindelinNov 7, 2007
  3. Pierre HabouzitNov 7, 2007
  4. JamesNov 7, 2007
  5. Johannes GilgerNov 7, 2007
  6. Pierre HabouzitNov 7, 2007
  7. Johannes GilgerNov 7, 2007
  8. JamesNov 7, 2007
  9. Daniel BarkalowNov 7, 2007
  10. Johannes SchindelinNov 7, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.