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

Re: Separate default remotes for pulling and pushing

From
Jeff King <peff@peff.net>
Date
May 9, 2011, 08:17 UTC
Message-ID
<20110509081708.GA5871@sigill.intra.peff.net>
In-Reply-To
<BANLkTinJDUa7sXjKHo81bG7KbnspxZ88oA@mail.gmail.com>
On Sat, May 07, 2011 at 11:50:35AM +0200, Sverre Rabbelier wrote:
Show 6 quoted lines
> On Sat, May 7, 2011 at 10:10, David Lee <davidomundo@gmail.com> wrote:
> > I want to set up different default remotes for pushing and pulling
> 
> See 'git remote set-url --push' [0].
> 
> [0] http://www.kernel.org/pub/software/scm/git/docs/git-remote.html

That probably doesn't quite do what David wants. It's useful when the URL for pushing and pulling a particular repository are different.

But if I understand it correctly, David has two _separate_ repositories. And using remote.*.pushurl for that has some unwanted side effects, because the tracking ref namespace (i.e., "remotes/origin/*") is shared by both, even though their refs may not be at the same position.

For example, when pushing "refs/heads/master" to the remote, git will update "refs/remotes/origin/master" to the pushed value. But that ref is supposed to reflect the value of the last fetch from his "original" repository, and now it doesn't. The ref value will flip back and forth between what's in the two repositories as he pushes and fetches.

I don't think there is currently a way to do what he wants. I think it would be useful for certain workflows. As I see it, there are a few pretty common setups for remotes:

  1. Centralized; you push and pull from a single repo, shared with
     other developers. In this case, you call it "origin" and everything
     is easy.
  2. Decentralized, you're the maintainer; you pull from other people or
     apply patches via email. When you push, you push out to some
     publishing point. You'd probably call your publishing point
     "origin" (though I think Junio calls kernel.org "ko" and just types
     "git push ko"). You never pull from some single place all the time,
     so you don't care about a shorthand for it.
  3. Decentralized, you're a developer with a patch-based workflow; you
     fetch from the maintainer, then develop and submit patches via a
     mailing list. You call the maintainer's repo "origin" and pull from
     it automatically.  You never push, so it doesn't matter that
     there's no shorthand.
  4. Decentralized, you're a developer that publishes work via git. You
     call the upstream maintainer "origin", so fetches are convenient
     (and git does this for you at clone, after all). But pushing, even
     though you probably always push to the same central, does not have
     a convenient shorthand.
     This is David's case (and mine, and I suspect some other git
     developers who do enough work that they want to make it publicly
     available via git, or even just have backups). It's also encouraged
     by sites like github, where you might clone the upstream's
     repository, but then pushes your changes up to a personal "fork"
     to let others see and merge them.

So I think part of the reason we don't have such an option is that cases 1-3 are so common. But it would be a nice convenience for people in case 4.

-Peff
Previous: Sverre RabbelierNext: David Lee
Message 3 of 14 in “Separate default remotes for pulling and pushing”
  1. David LeeMay 7, 2011
  2. Sverre RabbelierMay 7, 2011
  3. Jeff KingMay 9, 2011
  4. David LeeMay 9, 2011
  5. Jeff KingMay 9, 2011
  6. David LeeMay 9, 2011
  7. Jeff KingMay 9, 2011
  8. Junio C HamanoMay 9, 2011
  9. Jeff KingMay 9, 2011
  10. Junio C HamanoMay 9, 2011
  11. Jeff KingMay 10, 2011
  12. Jay SoffianMay 10, 2011
  13. Jeff KingMay 10, 2011
  14. Jay SoffianMay 10, 2011

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.