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

merge two local mirrors with detached heads and similar remotes

From
ZHZenaan Harkness <zen@freedbms.net>
Date
Nov 7, 2010, 02:40 UTC
Message-ID
<AANLkTinidbrJjmt5w=TyFGMyNpaGobE1iDBm3VAWmZvX@mail.gmail.com>

I wish to merge two local mirrors, which each should share the same object store, and I have been reading for many hours and so far failed to achieve.

I did learn  git remote add, and applied my knowledge to another local
git clone/ mirror as can be seen here:
$ cd bananajour.git/
$ git remote -v
eadz    https://github.com/eadz/bananajour.git (fetch)
eadz    https://github.com/eadz/bananajour.git (push)
fresh   https://github.com/freshtonic/bananajour.git (fetch)
fresh   https://github.com/freshtonic/bananajour.git (push)
origin  https://github.com/toolmantim/bananajour.git (fetch)
origin  https://github.com/toolmantim/bananajour.git (push)
ts      https://github.com/tswicegood/bananajour.git (fetch)
ts      https://github.com/tswicegood/bananajour.git (push)
$ gb -a
* master
  remotes/eadz/master
  remotes/eadz/railscamp-hackfest
  remotes/fresh/bigbananajour
  remotes/fresh/master
  remotes/fresh/railscamp-hackfest
  remotes/origin/HEAD -> origin/master
  remotes/origin/macruby
  remotes/origin/master
  remotes/origin/railscamp-hackfest
  remotes/origin/v3
  remotes/ts/master
  remotes/ts/railscamp-hackfest

So I want to achieve the same thing (multiple remotes in one local repo) for an earlier clone of two separate repos, which really ought to be just one, as follows:

A)
$ cd gitjour.git/
$ cat .git/config
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = https://github.com/chad/gitjour.git
[branch "master"]
        remote = origin
        merge = refs/heads/master
$ git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
B)
$ cd gitjour-new.git/
$ cat .git/config
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = https://github.com/lachlanhardy/gitjour.git
[branch "master"]
        remote = origin
        merge = refs/heads/master
$ git branch -a
* master
  remotes/origin/8.2.0
  remotes/origin/HEAD -> origin/master
  remotes/origin/lachlanhardy
  remotes/origin/master
  remotes/origin/v8.1.0

I tried, by copying each repo A) and B) into t/ and u/ respectively, then: $ cd t $ git remote add lach ../u $ git fetch latch

but I only get three resulting branches, not the expected 6:
$ gb -a
* master
  remotes/lach/master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master

I'm still learning my terminology sorry, but it seems that the origin branches in u/ are detached heads or something. That's fine, I just want them to appear in my t/ mirror.

I realise that I will need to update t/.git/config so that the "lach" remote points to its canonical/ web URL, but _first_ I want to get all the refs and objects from my local version, before hooking it up to the web for future updates. I want to take advantage of the download I've already done.

(Notwithstanding the fact that these repos are barely a few hundred KiB, I also need to do this job because my 18-month old linux repos are in a similar situation - I want to save my disk space by combining my Ubuntu Hardy linux repo (with it's branches/ heads), and a couple others, with my canonical Linus linux repo, into one. I did use the --reference option back when I made these repos respectively, to share and to minimize download as much as possible, but it seems that what I really want is a properly shared (single) repo with multiple remotes, so I don't have to think about what sequence of locals to download etc.

In this vein, a chapter in the tutorial, perhaps near 'recommended workflows', on Repository Mirroring Best Practices might be in order.

TIA Zenaan

Next: Zenaan Harkness
Message 1 of 4 in “merge two local mirrors with detached heads and similar remotes”
  1. Zenaan HarknessNov 7, 2010
  2. Zenaan HarknessNov 7, 2010
  3. Zenaan HarknessNov 7, 2010
  4. Jakub NarebskiNov 7, 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.