{"thread":{"id":"25659","subject":"merge two local mirrors with detached heads and similar remotes","startedAt":"2010-11-07T02:40:23Z","lastAt":"2010-11-07T11:52:39Z","messageCount":4,"participants":["Zenaan Harkness","Jakub Narebski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"155310","messageId":"AANLkTinidbrJjmt5w=TyFGMyNpaGobE1iDBm3VAWmZvX@mail.gmail.com","threadId":"25659","inReplyTo":null,"subject":"merge two local mirrors with detached heads and similar remotes","fromName":"Zenaan Harkness","fromEmail":"zen@freedbms.net","sentAt":"2010-11-07T02:40:23Z","receivedAt":"2010-11-07T02:40:23Z","isPatch":false,"sender":{"key":"zen@freedbms.net","avatar":null},"body":"I wish to merge two local mirrors, which each should share the same\nobject store, and I have been reading for many hours and so far failed\nto achieve.\n\nI did learn  git remote add, and applied my knowledge to another local\ngit clone/ mirror as can be seen here:\n$ cd bananajour.git/\n$ git remote -v\neadz    https://github.com/eadz/bananajour.git (fetch)\neadz    https://github.com/eadz/bananajour.git (push)\nfresh   https://github.com/freshtonic/bananajour.git (fetch)\nfresh   https://github.com/freshtonic/bananajour.git (push)\norigin  https://github.com/toolmantim/bananajour.git (fetch)\norigin  https://github.com/toolmantim/bananajour.git (push)\nts      https://github.com/tswicegood/bananajour.git (fetch)\nts      https://github.com/tswicegood/bananajour.git (push)\n$ gb -a\n* master\n  remotes/eadz/master\n  remotes/eadz/railscamp-hackfest\n  remotes/fresh/bigbananajour\n  remotes/fresh/master\n  remotes/fresh/railscamp-hackfest\n  remotes/origin/HEAD -> origin/master\n  remotes/origin/macruby\n  remotes/origin/master\n  remotes/origin/railscamp-hackfest\n  remotes/origin/v3\n  remotes/ts/master\n  remotes/ts/railscamp-hackfest\n\n\nSo I want to achieve the same thing (multiple remotes in one local\nrepo) for an earlier clone of two separate repos, which really ought\nto be just one, as follows:\n\nA)\n$ cd gitjour.git/\n$ cat .git/config\n[core]\n        repositoryformatversion = 0\n        filemode = true\n        bare = false\n        logallrefupdates = true\n[remote \"origin\"]\n        fetch = +refs/heads/*:refs/remotes/origin/*\n        url = https://github.com/chad/gitjour.git\n[branch \"master\"]\n        remote = origin\n        merge = refs/heads/master\n$ git branch -a\n* master\n  remotes/origin/HEAD -> origin/master\n  remotes/origin/master\n\nB)\n$ cd gitjour-new.git/\n$ cat .git/config\n[core]\n        repositoryformatversion = 0\n        filemode = true\n        bare = false\n        logallrefupdates = true\n[remote \"origin\"]\n        fetch = +refs/heads/*:refs/remotes/origin/*\n        url = https://github.com/lachlanhardy/gitjour.git\n[branch \"master\"]\n        remote = origin\n        merge = refs/heads/master\n$ git branch -a\n* master\n  remotes/origin/8.2.0\n  remotes/origin/HEAD -> origin/master\n  remotes/origin/lachlanhardy\n  remotes/origin/master\n  remotes/origin/v8.1.0\n\n\nI tried, by copying each repo A) and B) into t/ and u/ respectively, then:\n$ cd t\n$ git remote add lach ../u\n$ git fetch latch\n\nbut I only get three resulting branches, not the expected 6:\n$ gb -a\n* master\n  remotes/lach/master\n  remotes/origin/HEAD -> origin/master\n  remotes/origin/master\n\n\nI'm still learning my terminology sorry, but it seems that the origin\nbranches in u/ are detached heads or something. That's fine, I just\nwant them to appear in my t/ mirror.\n\nI realise that I will need to update t/.git/config so that the \"lach\"\nremote points to its canonical/ web URL, but _first_ I want to get all\nthe refs and objects from my local version, before hooking it up to\nthe web for future updates. I want to take advantage of the download\nI've already done.\n\n(Notwithstanding the fact that these repos are barely a few hundred\nKiB, I also need to do this job because my 18-month old linux repos\nare in a similar situation - I want to save my disk space by combining\nmy Ubuntu Hardy linux repo (with it's branches/ heads), and a couple\nothers, with my canonical Linus linux repo, into one. I did use the\n--reference option back when I made these repos respectively, to share\nand to minimize download as much as possible, but it seems that what I\nreally want is a properly shared (single) repo with multiple remotes,\nso I don't have to think about what sequence of locals to download\netc.\n\nIn this vein, a chapter in the tutorial, perhaps near 'recommended\nworkflows', on Repository Mirroring Best Practices might be in order.\n\nTIA\nZenaan\n"},{"id":"155313","messageId":"AANLkTi=JmpXEiEe-7-ZicUp-QosWjTZQgK77-f=9iAtL@mail.gmail.com","threadId":"25659","inReplyTo":"AANLkTinidbrJjmt5w=TyFGMyNpaGobE1iDBm3VAWmZvX@mail.gmail.com","subject":"Re: merge two local mirrors with detached heads and similar remotes","fromName":"Zenaan Harkness","fromEmail":"zen@freedbms.net","sentAt":"2010-11-07T09:27:50Z","receivedAt":"2010-11-07T09:27:50Z","isPatch":false,"sender":{"key":"zen@freedbms.net","avatar":null},"body":"On Sun, Nov 7, 2010 at 13:40, Zenaan Harkness <zen@freedbms.net> wrote:\n> I wish to merge two local mirrors, which each should share the same\n> object store\n...\n> So I want to achieve the same thing (multiple remotes in one local\n> repo) for an earlier clone of two separate repos, which really ought\n> to be just one, as follows:\n>\n> A)\n> $ cd gitjour.git/\n> $ cat .git/config\n\n> [remote \"origin\"]\n>        fetch = +refs/heads/*:refs/remotes/origin/*\n>        url = https://github.com/chad/gitjour.git\n> [branch \"master\"]\n>        remote = origin\n>        merge = refs/heads/master\n\n> $ git branch -a\n> * master\n>  remotes/origin/HEAD -> origin/master\n>  remotes/origin/master\n>\n> B)\n> $ cd gitjour-new.git/\n> $ cat .git/config\n\n> [remote \"origin\"]\n>        fetch = +refs/heads/*:refs/remotes/origin/*\n>        url = https://github.com/lachlanhardy/gitjour.git\n> [branch \"master\"]\n>        remote = origin\n>        merge = refs/heads/master\n> $ git branch -a\n> * master\n>  remotes/origin/8.2.0\n>  remotes/origin/HEAD -> origin/master\n>  remotes/origin/lachlanhardy\n>  remotes/origin/master\n>  remotes/origin/v8.1.0\n\nIt looks to me like I finally solved the first half of the problem,\nwith clarification from the following URL:\nhttp://www.gelato.unsw.edu.au/archives/git/0601/15567.html\n\nIn A) I modified .git/config to be as follows:\n$ cat .git/config\n[core]\n        repositoryformatversion = 0\n        filemode = true\n        bare = false\n        logallrefupdates = true\n[remote \"origin\"]\n        fetch = +refs/heads/*:refs/remotes/origin/*\n        url = https://github.com/chad/gitjour.git\n[branch \"master\"]\n        remote = origin\n        merge = refs/heads/master\n[remote \"lach\"]\n        url = ../u\n#       fetch = +refs/heads/*:refs/remotes/origin/*\n        fetch = +refs/remotes/origin/*:refs/remotes/lach/*\n$ git fetch lach d\nremote: Counting objects: 583, done.\nremote: Compressing objects: 100% (303/303), done.\nremote: Total 568 (delta 229), reused 566 (delta 229)\nReceiving objects: 100% (568/568), 65.29 KiB, done.\nResolving deltas: 100% (229/229), completed with 3 local objects.\nFrom ../u\n * [new branch]      origin/8.2.0 -> lach/8.2.0\n * [new branch]      origin/HEAD -> lach/HEAD\n * [new branch]      origin/lachlanhardy -> lach/lachlanhardy\n * [new branch]      origin/v8.1.0 -> lach/v8.1.0\n\n# and finally:\n$ git branch -a\n* master\n  remotes/lach/8.2.0\n  remotes/lach/HEAD\n  remotes/lach/lachlanhardy\n  remotes/lach/master\n  remotes/lach/v8.1.0\n  remotes/origin/HEAD -> origin/master\n  remotes/origin/master\n\n---------\nLooks very much like success to me. Small thing I notice is this line:\n  remotes/origin/HEAD -> origin/master\n\nhas become this:\n  remotes/lach/HEAD\n\n(ie it's not a link any more - probably not particularly relevant,\nperhaps git gc would automate tidying this?)\n----------\nSo now I just update the remote URL for lach to point back to upstream\nand I think I'm done. Happy days.\n\nThat tutorial email URL up top above might be old -\nhttp://www.gelato.unsw.edu.au/archives/git/0601/15567.html is from\nJanuary 2006! - and is out of date a bit wrt the .git/config file\nformat (eg remotes wildcards), BUT in that email, Junio explained this\n\"local mirror\" concept well enough that I could solve my problem here\n(it appears) - implementing a fixup of my \"local mirror\" use case -\nI'm a happy camper; thank you Junio!\n\nMay be I missed how to do this somewhere in the docs already, but I've\nbeen reading and searching the web for two days, learning lots for\nsure, but frustrated that it took me so long to find out how to do\nthis.\n\nShould something like Junio's tutorial go into\nDocumentation/gitworkflows.xml(ARGGH!) ?\nIf not, where else?\nIs there anything besides vim (about all I know) you can recommend for\nediting xml(ARGGH!) docs?\n\nThanks\nZenaan\n"},{"id":"155317","messageId":"AANLkTin5GOGO3sf7kTjOz8X-rfiFTW6rTD5cO6w4p2yA@mail.gmail.com","threadId":"25659","inReplyTo":"AANLkTi=JmpXEiEe-7-ZicUp-QosWjTZQgK77-f=9iAtL@mail.gmail.com","subject":"Re: merge two local mirrors with detached heads and similar remotes","fromName":"Zenaan Harkness","fromEmail":"zen@freedbms.net","sentAt":"2010-11-07T09:42:46Z","receivedAt":"2010-11-07T09:42:46Z","isPatch":false,"sender":{"key":"zen@freedbms.net","avatar":null},"body":"> In A) I modified .git/config to be as follows:\n> $ cat .git/config\n> [core]\n>        repositoryformatversion = 0\n>        filemode = true\n>        bare = false\n>        logallrefupdates = true\n> [remote \"origin\"]\n>        fetch = +refs/heads/*:refs/remotes/origin/*\n>        url = https://github.com/chad/gitjour.git\n> [branch \"master\"]\n>        remote = origin\n>        merge = refs/heads/master\n> [remote \"lach\"]\n>        url = ../u\n> #       fetch = +refs/heads/*:refs/remotes/origin/*\n>        fetch = +refs/remotes/origin/*:refs/remotes/lach/*\n\nMy final change, for reference, was updating [remote \"latch\"] section with:\n   url = https://github.com/lachlanhardy/gitjour.git\n   fetch = +refs/heads/*:refs/remotes/lach/*\n\nAppears to work with  git fetch --all\nand finally followed by  git gc\n"},{"id":"155321","messageId":"m3vd49fj1k.fsf@localhost.localdomain","threadId":"25659","inReplyTo":"AANLkTi=JmpXEiEe-7-ZicUp-QosWjTZQgK77-f=9iAtL@mail.gmail.com","subject":"Re: merge two local mirrors with detached heads and similar remotes","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2010-11-07T11:52:39Z","receivedAt":"2010-11-07T11:52:39Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Zenaan Harkness <zen@freedbms.net> writes:\n\n> ---------\n> Looks very much like success to me. Small thing I notice is this line:\n>   remotes/origin/HEAD -> origin/master\n> \n> has become this:\n>   remotes/lach/HEAD\n> \n> (ie it's not a link any more - probably not particularly relevant,\n> perhaps git gc would automate tidying this?)\n\nIt might be detached head: you can check it by using\n\n  $ git rev-parse --symbolic-full-name remotes/lach/HEAD\n\nIf it is 'remotes/lach/HEAD' or 'HEAD', it is detached HEAD\n(unnamed branch).\n\n\n> Should something like Junio's tutorial go into\n> Documentation/gitworkflows.xml(ARGGH!) ?\n> If not, where else?\n> Is there anything besides vim (about all I know) you can recommend for\n> editing xml(ARGGH!) docs?\n\nDocumentation/gitworkflows.txt is source of XML, HTML, info and\nmanpage versions - please edit source (in AsciiDoc), and not generated\ndocumentation.\n\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"}]}