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

Re: Separate default push/pull?

From
Jeff King <peff@peff.net>
Date
Feb 12, 2010, 00:14 UTC
Message-ID
<20100212001417.GC21930@coredump.intra.peff.net>
In-Reply-To
<a038bef51002111057l382ed55fy6b4042d1115a830c@mail.gmail.com>
On Thu, Feb 11, 2010 at 01:57:34PM -0500, Chris Packham wrote:
Show 16 quoted lines
> Taking a quick look at the git push --help you'll see the following
> snippet of configuration.
> 
>                    [remote "<name>"]
>                            url = <url>
>                            pushurl = <pushurl>
>                            push = <refspec>
>                            fetch = <refspec>
> 
> so I think if you just add the pushurl to your .git/config should do
> what you've asked
> 
> [remote "origin"]
>         fetch = +refs/heads/*:refs/remotes/origin/*
>         url = git://git.kernel.org/pub/scm/git/git.git
>         pushurl = git://git.example.com/yourrepo.git

That's not quite what David wants, I think. That is a good recipe if you have two ways of accessing the same repo (usually git:// for reading and ssh for pushing). But if the two URLs actually point to _different_ repos, you will get some confusing results. For example, pushing to your private repo will update the tracking branches in refs/remotes/origin/* with values that do not match what is in the actual origin repository.

Show 6 quoted lines
>   git remote add yourrepo git://git.example.com/yourrepo.git
>   git push yourrepo master:refs/heads/master  # the first time
>   git push yourrepo # subsequent times
> 
> There probably is a way to tell push to use something other than
> "origin" by default but I don't know/can't find it.

I don't think there is currently a way to do what he wants. You can set a default remote name by setting branch.*.remote, but that has two problems:

  1. It is also used to determine the upstream remote for pulling and
     for calculating upstream tracking branches. So he probably wants to
     leave it set as origin.
  2. It would have to be set manually for every branch.

I think what he would need is a "push.defaultRemote" config option, which universally overrides branch.*.remote for pushing.

-Peff
Previous: Chris PackhamNext: Junio C Hamano
Message 3 of 8 in “Separate default push/pull?”
  1. David AbrahamsFeb 11, 2010
  2. Chris PackhamFeb 11, 2010
  3. Jeff KingFeb 12, 2010
  4. Junio C HamanoFeb 12, 2010
  5. Jeff KingFeb 12, 2010
  6. Junio C HamanoFeb 12, 2010
  7. Jeff KingFeb 13, 2010
  8. David AbrahamsFeb 12, 2010

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.