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

'upstream' branches.

From
David Woodhouse <dwmw2@infradead.org>
Date
May 5, 2007, 12:29 UTC
Message-ID
<1178368166.11851.60.camel@pmac.infradead.org>

When creating a repository which may pull from one or more 'upstream' repositories, it's useful to keep 'branches' which keep track of the last pull from those upstream repositories -- either directly or indirectly.

At http://www.linux-mtd.infradead.org/doc/git.html I've described the setup I'm currently using to achieve this, which looks something like the following:

[remote "origin"]
        url = ssh://git.infradead.org/~/public_git/foo-2.6.git
        fetch = +refs/heads/*:refs/remotes/origin/*
	fetch = +refs/heads/mtd:refs/heads/mtd
	fetch = +refs/heads/linus:refs/heads/linus
        push = refs/heads/master:refs/heads/master
        push = refs/heads/mtd:refs/heads/mtd
        push = refs/heads/linus:refs/heads/linus
[branch "master"]
        remote = origin
        merge = refs/heads/master
[remote "mtd"]
        url = git://git.infradead.org/mtd-2.6.git
        fetch = refs/heads/master:refs/heads/mtd
        fetch = +refs/heads/linus:refs/heads/linus
[remote "linus"]
        url = git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.$
        fetch = refs/heads/master:refs/heads/linus

Is there a better way to do this? Preferably which doesn't involve directing the user to edit .git/config directly?

Basically, I want the local 'linus' branch to be updated whenever the user pulls from _any_ other repository with a 'linus' branch, so that the 'linus' branch always represents the latest commit pulled from upstream. Likewise, the 'mtd' branch should be updated when pulling from that tree (or any other dependent tree which will have an 'mtd' branch).

These branches should be pushed back to the origin each time.

What I have at the moment isn't ideal because I think pulling from the 'mtd' tree will fail if the 'linus' branch there is older than the local clone's 'linus' branch. But it mostly works.

Is there a better way?
-- 
dwmw2
Next: Alex Riesen
Message 1 of 13 in “'upstream' branches.”
  1. David WoodhouseMay 5, 2007
  2. Alex RiesenMay 5, 2007
  3. David WoodhouseMay 5, 2007
  4. Alex RiesenMay 5, 2007
  5. Junio C HamanoMay 6, 2007
  6. David WoodhouseMay 6, 2007
  7. Junio C HamanoMay 6, 2007
  8. David WoodhouseMay 6, 2007
  9. Junio C HamanoMay 7, 2007
  10. David WoodhouseMay 7, 2007
  11. Alex RiesenMay 6, 2007
  12. Junio C HamanoMay 7, 2007
  13. Alex RiesenMay 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.