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

Re: Separate default push/pull?

From
Chris Packham <judge.packham@gmail.com>
Date
Feb 11, 2010, 18:57 UTC
Message-ID
<a038bef51002111057l382ed55fy6b4042d1115a830c@mail.gmail.com>
In-Reply-To
<m2zl3fg26j.fsf@boostpro.com>
On Thu, Feb 11, 2010 at 11:36 AM, David Abrahams <dave@boostpro.com> wrote:
Show 18 quoted lines
>
> If I am collaborating mostly with one other person, I typically want to
> pull from his publicly-readable repo and push to mine (on which I have
> write permission).  Is there any way to set things up so “git pull” and
> “git push” without additional arguments will do this by default?
>
> Thanks,
>
> --
> Dave Abrahams           Meet me at BoostCon: http://www.boostcon.com
> BoostPro Computing
> http://www.boostpro.com
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

Yes there is a way. I haven't used it myself but search this list and you'll find plenty of references.

(disclaimer: the following is what I think you can do based on some vague recollection and some man pages)

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

For your own sanity I suggest doing this by adding your repository as a separate remote.

e.g.
  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.

Previous: David AbrahamsNext: Jeff King
Message 2 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.