{"thread":{"id":"11205","subject":"How-to combine several separate git repos?","startedAt":"2007-12-09T06:34:01Z","lastAt":"2007-12-10T17:55:15Z","messageCount":13,"participants":["Wink Saville","Alex Riesen","Daniel Barkalow"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"62458","messageId":"475B8C59.7050707@saville.com","threadId":"11205","inReplyTo":null,"subject":"How-to combine several separate git repos?","fromName":"Wink Saville","fromEmail":"wink@saville.com","sentAt":"2007-12-09T06:34:01Z","receivedAt":"2007-12-09T06:34:01Z","isPatch":false,"sender":{"key":"wink@saville.com","avatar":"https://avatars.githubusercontent.com/u/1024284?v=4"},"body":"I've got several git repositories of different projects and was thinking\nI should combine into one repository, but my googling around didn't turn up\nany simple way of doing it.\n\nAny advice?\n\nWink Saville\n"},{"id":"62479","messageId":"20071209104336.GA3163@steel.home","threadId":"11205","inReplyTo":"475B8C59.7050707@saville.com","subject":"Re: How-to combine several separate git repos?","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-12-09T10:43:36Z","receivedAt":"2007-12-09T10:43:36Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Wink Saville, Sun, Dec 09, 2007 07:34:01 +0100:\n> I've got several git repositories of different projects and was thinking\n> I should combine into one repository, but my googling around didn't turn up\n> any simple way of doing it.\n>\n> Any advice?\n\nShould they both be visible in one working tree as directories?\nShould these be independent branches?\n\nFor instance, you can fetch one into another:\n\n    $ cd project1\n    $ git config remote.project2.url /path/to/project2\n    $ git config remote.project2.fetch 'refs/heads/*:refs/project2/*'\n    $ git fetch project\n\nThat will give you two (or more) branches, containing history of the\nproject1 and project2. They are still completely independent, just use\nthe same object store.\n\nYou can merge them, for example:\n\n    $ cd project1\n    $ git merge project2/master\n\nAssuming that there is no filename collisions you'll get a repo with\ntwo merged histories (and two starting points). In case you get\nconflicts you can either resolve them by editing or just move the\nproblematic project in subdirectory:\n\n    $ git merge -s ours --no-commit project2/master\n    Automatic merge went well; stopped before committing as requested\n\nhere will be no conflicts. Merge strategy \"ours\" (-s ours) does not\ntake anything from the branch to be merged. The coolest strategy ever.\n\"--no-commit\" stops the operation just before committing.\n\n    $ git read-tree --prefix=project2/ project2/master\n    $ git checkout-index -a\n    $ git commit\n\nThat's it. The histories are merged and the files of project2 are\nplaced in the directory \"project2\". It is a wee bit harder to browse\nthe history of the files: you have to give both new and \"old\" name of\nthe project2's files, as if you renamed them (that's what read-tree\nwith --prefix did).\n"},{"id":"62512","messageId":"475C3E25.30704@saville.com","threadId":"11205","inReplyTo":"20071209104336.GA3163@steel.home","subject":"Re: How-to combine several separate git repos?","fromName":"Wink Saville","fromEmail":"wink@saville.com","sentAt":"2007-12-09T19:12:37Z","receivedAt":"2007-12-09T19:12:37Z","isPatch":false,"sender":{"key":"wink@saville.com","avatar":"https://avatars.githubusercontent.com/u/1024284?v=4"},"body":"Alex Riesen wrote:\n> Wink Saville, Sun, Dec 09, 2007 07:34:01 +0100:\n>   \n>> I've got several git repositories of different projects and was thinking\n>> I should combine into one repository, but my googling around didn't turn up\n>> any simple way of doing it.\n>>\n>> Any advice?\n>>     \n>\n> Should they both be visible in one working tree as directories?\n>   \nYes, I currently have:\n\n  ~/prgs/android/StateMachine\n  ~/prgs/android/test2\n  ~/prgs/android/test-annotation\n\nI'd with 3 git repo's in StateMachine, test2 & test-annotation.\nIdeally I was thinking having using submodules as they\nseparate but related. But not sure submodules are ready.\n> Should these be independent branches?\n>\n> For instance, you can fetch one into another:\n>\n>     $ cd project1\n>     $ git config remote.project2.url /path/to/project2\n>     $ git config remote.project2.fetch 'refs/heads/*:refs/project2/*'\n>     $ git fetch project\n>\n> That will give you two (or more) branches, containing history of the\n> project1 and project2. They are still completely independent, just use\n> the same object store.\n>   \nSo the above isn't what I want, but for grins I tried it, and got to\nthis point:\n\nwink@ic2d1:$ cd StateMachine\nwink@ic2d1:$ cat .git/config\n[core]\n        repositoryformatversion = 0\n        filemode = true\n        bare = false\n        logallrefupdates = true\nwink@ic2d1:$ git config remote.test2.url ../test2\nwink@ic2d1:$ git config remote.test2.fetch 'refs/heads/*:refs/test2/*'\nwink@ic2d1:$ cat .git/config\n[core]\n        repositoryformatversion = 0\n        filemode = true\n        bare = false\n        logallrefupdates = true\n[remote \"test2\"]\n        url = ../test2\n        fetch = refs/heads/*:refs/test2/*\nwink@ic2d1:$ git fetch test2\nwarning: no common commits\nremote: Counting objects: 24, done.  \nremote: Compressing objects: 100% remote: (16/16), done.  \nremote: Total 24 (delta 3), reused 0 (delta 0)\nUnpacking objects: 100% (24/24), done.  \n From ../test2\n * [new branch]      master -> refs/test2/master\nwink@ic2d1:$ git checkout -b test2 test2/master\nBranch test2 set up to track remote branch refs/test2/master.\nSwitched to a new branch \"test2\"\nwink@ic2d1:$ git status\n# On branch test2\nnothing to commit (working directory clean)\nwink@ic2d1:$ git status\n# On branch test2\nnothing to commit (working directory clean)\nwink@ic2d1:$ git branch -a\n  master\n* test2\nwink@ic2d1:$ git checkout master\nSwitched to branch \"master\"\nwink@ic2d1:$ git checkout test2\nSwitched to branch \"test2\"\n\nSo that worked, but as I mentioned not quite what I want\nas I want to \"see\" them all simultaneously.\n\n> You can merge them, for example:\n>\n>     $ cd project1\n>     $ git merge project2/master\n>   \nStarting over (restoring the original from a tar backup)\nthis didn't work I get:\n\nwink@ic2d1:$ cd StateMachine\nwink@ic2d1:$ git merge ../test2/master\n../test2/master - not something we can merge\n\n> Assuming that there is no filename collisions you'll get a repo with\n> two merged histories (and two starting points). In case you get\n> conflicts you can either resolve them by editing or just move the\n> problematic project in subdirectory:\n>\n>     $ git merge -s ours --no-commit project2/master\n>     Automatic merge went well; stopped before committing as requested\n>\n> here will be no conflicts. Merge strategy \"ours\" (-s ours) does not\n> take anything from the branch to be merged. The coolest strategy ever.\n> \"--no-commit\" stops the operation just before committing.\n>\n>     $ git read-tree --prefix=project2/ project2/master\n>     $ git checkout-index -a\n>     $ git commit\n>\n> That's it. The histories are merged and the files of project2 are\n> placed in the directory \"project2\". It is a wee bit harder to browse\n> the history of the files: you have to give both new and \"old\" name of\n> the project2's files, as if you renamed them (that's what read-tree\n> with --prefix did).\n>\n>   \nSo the first suggestion works, but I don't want them as\nseparate branches as I want to work on the simultaneously\nand they'll share common code.\n\nAnother option I was thinking would work for me would be to use\nsubmodules. But I'm not sure submodules are ready for\nneophytes and maybe it doesn't do what I want?\n\nThanks,\n\nWink Saville\n"},{"id":"62518","messageId":"Pine.LNX.4.64.0712091445470.5349@iabervon.org","threadId":"11205","inReplyTo":"475C3E25.30704@saville.com","subject":"Re: How-to combine several separate git repos?","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2007-12-09T19:55:58Z","receivedAt":"2007-12-09T19:55:58Z","isPatch":false,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Sun, 9 Dec 2007, Wink Saville wrote:\n\n> Another option I was thinking would work for me would be to use\n> submodules. But I'm not sure submodules are ready for\n> neophytes and maybe it doesn't do what I want?\n\nI think that submodules do what you want. And they may not be ready for \nneophytes to just use, but they're ready for neophytes to try using and \ntell us where things get confused. That is, I don't think git developers \nknow of anything still wrong with submodules, so we need people to try \nusing them and say \"I can't use submodules now because...\". Or, of course, \nthe code might be fine now and the discussion just too intimidating.\n\nIn any case, if you create a new repository, and fetch stuff into it, and \ndon't push stuff back, you can't screw up the original (obviously), so it \nshould be safe and possibly informative to play around with submodules.\n\n\t-Daniel\n*This .sig left intentionally blank*\n"},{"id":"62525","messageId":"475C7DD5.9040209@saville.com","threadId":"11205","inReplyTo":"Pine.LNX.4.64.0712091445470.5349@iabervon.org","subject":"Re: How-to combine several separate git repos?","fromName":"Wink Saville","fromEmail":"wink@saville.com","sentAt":"2007-12-09T23:44:21Z","receivedAt":"2007-12-09T23:44:21Z","isPatch":false,"sender":{"key":"wink@saville.com","avatar":"https://avatars.githubusercontent.com/u/1024284?v=4"},"body":"Daniel Barkalow wrote:\n> On Sun, 9 Dec 2007, Wink Saville wrote:\n>\n>   \n> I think that submodules do what you want. And they may not be ready for \n> neophytes to just use, but they're ready for neophytes to try using and \n> tell us where things get confused.\n>   \n<snip>\n> \t-Daniel\nI would like to try submodules and started to  read the man\n\n\nI'll try submodules and I'll start by reading the man page,\nI got to \"add\" and did the following:\n\nwink@ic2d1:$ mkdir x\nwink@ic2d1:$ cd x\nwink@ic2d1:$ git init\nInitialized empty Git repository in .git/\nwink@ic2d1:$ git-submodule add ../android/StateMachine\nremote (origin) does not have a url in .git/config\nyou must specify a repository to clone.\nClone of '' into submodule path 'StateMachine' failed\n\nThe documentation for \"submodule add\" says:\n\n/git-submodule/ [--quiet] [-b branch] add <repository> [<path>]\nAdd the given repository as a submodule at the given path to the \nchangeset to be committed next.\n\n From the above, <path> is ambiguous to me, is it referring to the \nsource or destination. I continue reading and in the options section we \nfind:\n\n<path>\n\n    Path to submodule(s). When specified this will restrict the command\n    to only operate on the submodules found at the specified paths.\n\n\nSo it seems <path> is the for the source, but some how it can specify \nmultiple paths. This seems to imply that I could add my three \nrepositories with one command. But I have no idea how and there are no \nexamples, but I can guess for my three repositories maybe:\n\nwink@ic2d1:$ rm -rf *\nwink@ic2d1:$ git init\nInitialized empty Git repository in .git/\nwink@ic2d1:$ git add submodule ../android StateMachine test2 test-annotation\nfatal: '../android' is outside repository\n\nNope that didn't work, continue reading, ah I probably need to \n\"submodule init\" first.\nIt says:\n\ninit\n\n    Initialize the submodules, i.e. register in .git/config each\n    submodule name and url found in .gitmodules. The key used in\n    .git/config is submodule.$name.url. This command does not alter\n    existing information in .git/config.\n\nThis is garbally-gok to me (remember, neophyte) but it does leave a clue,\napparently I need to create .gitmodules so I do:\n\nwink@ic2d1:$ cat .gitmodules\n[submodule \"StateMachine\"]\n        path = StateMachine\n        url = ../android/StateMachine\n\n[submodule \"test2\"]\n        path = test2\n        url = ../android/test2\n\n[submodule \"test-annotation\"]\n        path = test2\n        url = ../android/test-annotation\n\nSo now I:\n\nwink@ic2d1:$ cd ..\nwink@ic2d1:$ rm -rf x\nwink@ic2d1:$ mkdir x\nwink@ic2d1:$ cd x\nwink@ic2d1:$ git init\nInitialized empty Git repository in .git/\nwink@ic2d1:$ cat .git/config\n[core]\n        repositoryformatversion = 0\n        filemode = true\n        bare = false\n        logallrefupdates = true\nwink@ic2d1:$ cp ../gitmodules .gitmodules\nwink@ic2d1:$ cat .gitmodules\n[submodule \"StateMachine\"]\n        path = StateMachine\n        url = ../android/StateMachine\n\n[submodule \"test2\"]\n        path = test2\n        url = ../android/test2\n\n[submodule \"test-annotation\"]\n        path = test2\n        url = ../android/test-annotation\n\nwink@ic2d1:$ git submodule init\nwink@ic2d1:$ cat .git/config\n[core]\n        repositoryformatversion = 0\n        filemode = true\n        bare = false\n        logallrefupdates = true\n\n\nThat's not what I expected according to the documentation I was\nexpecting .git/config to now contain the [submodule \"xxx\"] sections\nfrom .gitmodules? But maybe I've got to \"submodule add\" first or ...\n\nWell, this isn't getting me anywhere so Daniel, I hope that gives\nyou some insight from a newbies point of view.\n\nMy first comment is that needs to be some examples in git submodule help.\nSecond, I'd suggest .gitmodules be called .gitsubmodules and that\nthe documentation have a related name. I went into the git/Documentation\ndirectory in my clone of git and looked for \"find . -iname '*sub*' and\nthe only relevant the files were for git-submodule I see no reason for there\nnot be a a .gitsubmodule. Actually, at the moment I see no reason for\nthis file at all, but that will probably become apparent soon:)\n \nNote, my git current version is:\n\nwink@ic2d1:$ git --version\ngit version 1.5.3.5.622.g6fd7a\n\nI've cloned git and built locally so I can change to what ever version\nis appropriate. For now I'll search around on the web\n\n\nThanks,\n\nWink Saville\n"},{"id":"62529","messageId":"Pine.LNX.4.64.0712091942520.5349@iabervon.org","threadId":"11205","inReplyTo":"475C7DD5.9040209@saville.com","subject":"Re: How-to combine several separate git repos?","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2007-12-10T01:11:06Z","receivedAt":"2007-12-10T01:11:06Z","isPatch":false,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Sun, 9 Dec 2007, Wink Saville wrote:\n\n> Daniel Barkalow wrote:\n> > On Sun, 9 Dec 2007, Wink Saville wrote:\n> >\n> >   I think that submodules do what you want. And they may not be ready for\n> > neophytes to just use, but they're ready for neophytes to try using and tell\n> > us where things get confused.\n> >   \n> <snip>\n> >  -Daniel\n> I would like to try submodules and started to  read the man\n> \n> \n> I'll try submodules and I'll start by reading the man page,\n> I got to \"add\" and did the following:\n> \n> wink@ic2d1:$ mkdir x\n> wink@ic2d1:$ cd x\n> wink@ic2d1:$ git init\n> Initialized empty Git repository in .git/\n> wink@ic2d1:$ git-submodule add ../android/StateMachine\n> remote (origin) does not have a url in .git/config\n> you must specify a repository to clone.\n> Clone of '' into submodule path 'StateMachine' failed\n\nIt looks like git-submodule does something really wrong for URLs that \nstart with ./ or ../. (By \"wrong\", I mean that it's different from the \nhandling of the same URL anywhere else.) I think there's a general problem \n(beyond submodule support) that git doesn't do a good job with \nintermediate repositories: if you clone a repository, and then clone the \nclone, the second clone sees the local-to-the-first aspects and largely \nignores the actual origin's properties.\n\nOn the other hand, you probably don't really want the canonical URL for \nthe submodule to be a local relative path. If what you have are local \nclones of public repositories, you want to use the public remote \nrepositories' URLs there. If you really want it to be a clone of the local \nrepository, you can use an absolute path and weird things won't happen.\n\nI think it should be possible to store the submodule data in the 'x' \nrepository as well; have some branches which are the three different \nprojects, and then pull them out of '.', but this doesn't seem to be \nworking for me, either.\n\n> The documentation for \"submodule add\" says:\n> \n> /git-submodule/ [--quiet] [-b branch] add <repository> [<path>]\n> Add the given repository as a submodule at the given path to the changeset to\n> be committed next.\n> \n> From the above, <path> is ambiguous to me, is it referring to the source or\n> destination. I continue reading and in the options section we find:\n> \n> <path>\n> \n>    Path to submodule(s). When specified this will restrict the command\n>    to only operate on the submodules found at the specified paths.\n> \n> So it seems <path> is the for the source, but some how it can specify multiple\n> paths.\n\nThis is actually the destination. The projects that are under discussion \nare only submodules in the context of the destination. For \"git submodule \nadd\" it's the path in the superproject where the submodule will appear.\n\n\t-Daniel\n*This .sig left intentionally blank*\n"},{"id":"62530","messageId":"475CA476.6070507@saville.com","threadId":"11205","inReplyTo":"Pine.LNX.4.64.0712091942520.5349@iabervon.org","subject":"Re: How-to combine several separate git repos?","fromName":"Wink Saville","fromEmail":"wink@saville.com","sentAt":"2007-12-10T02:29:10Z","receivedAt":"2007-12-10T02:29:10Z","isPatch":false,"sender":{"key":"wink@saville.com","avatar":"https://avatars.githubusercontent.com/u/1024284?v=4"},"body":"Daniel Barkalow wrote:\n> On Sun, 9 Dec 2007, Wink Saville wrote:\n>   \n> <snip>\n>   \n\nI got submodule working, buy following the tutorial here:\nhttp://git.or.cz/gitwiki/GitSubmoduleTutorial#preview.\n\nAs well as looking at:\nhttp://jonathan.tron.name/articles/2007/09/15/git-1-5-3-submodule\nhttp://en.wikibooks.org/wiki/Source_Control_Management_With_Git/Submodules_and_Superprojects#endnote_lie_parent\nhttp://kerneltrap.org/mailarchive/git/2007/10/19/348810\nhttp://kerneltrap.org/mailarchive/git/2007/10/19/348829\n\nI'd say the current documentation in git needs to improve at least\nfor neophytes. The first step would be to include the GitSubmoduleTutorial.\nAlso, I think the second paragraph of the tutorial is very important and\nsomething like it should probably be the first paragraph of the \ngit-submodule\nman page:\n\n\"Submodules maintain their own identity; the submodule support just \nstores the submodule repository location and commit ID, so other \ndevelopers who clone the superproject can easily clone all the \nsubmodules at the same revision.\"\n\nMy interpretation of the paragraph and how submodules might be used\nis that the \"supermodule\" provides tags for a set of repositories.\nI see that as important, especially for large projects which could use\nmultiple repositories for sub-projects and then use a \"supermodule\"\nfor test and release management.\n\nThat isn't what I really wanted to do. As a one man band I was looking\nto actually \"combine\" several repositories into one logical repository\nto simplify commits, pushes, pulls to my own backup repositories.\nI now see that that wasn't the purpose of submodule.\n\nAnyway, that is the perspective of this neophyte and I learned something\nnew which is a primary goal of mine.\n\nFinally, I'm back to my original question how to combine repositories? As\nI said in my response to Alex, the multiple branches I got working but that\nisn't what I want.\n\nWhat I think I now want is to create a new repository which contains my\nother repositories as sub-directories (with their histories) after combining\nthem I would delete the old repositories. I expect the resulting history\nto be sequential, with the sequence defined by the order I combine them,\nbut maybe there is another choice?\n\n\nCheers,\n\nWink Saville\n"},{"id":"62532","messageId":"Pine.LNX.4.64.0712092130560.5349@iabervon.org","threadId":"11205","inReplyTo":"475CA476.6070507@saville.com","subject":"Re: How-to combine several separate git repos?","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2007-12-10T03:01:03Z","receivedAt":"2007-12-10T03:01:03Z","isPatch":false,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Sun, 9 Dec 2007, Wink Saville wrote:\n\n> Daniel Barkalow wrote:\n> > On Sun, 9 Dec 2007, Wink Saville wrote:\n> >   <snip>\n> >   \n> \n> I got submodule working, buy following the tutorial here:\n> http://git.or.cz/gitwiki/GitSubmoduleTutorial#preview.\n> \n> As well as looking at:\n> http://jonathan.tron.name/articles/2007/09/15/git-1-5-3-submodule\n> http://en.wikibooks.org/wiki/Source_Control_Management_With_Git/Submodules_and_Superprojects#endnote_lie_parent\n> http://kerneltrap.org/mailarchive/git/2007/10/19/348810\n> http://kerneltrap.org/mailarchive/git/2007/10/19/348829\n> \n> I'd say the current documentation in git needs to improve at least\n> for neophytes. The first step would be to include the GitSubmoduleTutorial.\n> Also, I think the second paragraph of the tutorial is very important and\n> something like it should probably be the first paragraph of the git-submodule\n> man page:\n> \n> \"Submodules maintain their own identity; the submodule support just stores the\n> submodule repository location and commit ID, so other developers who clone the\n> superproject can easily clone all the submodules at the same revision.\"\n> \n> My interpretation of the paragraph and how submodules might be used\n> is that the \"supermodule\" provides tags for a set of repositories.\n> I see that as important, especially for large projects which could use\n> multiple repositories for sub-projects and then use a \"supermodule\"\n> for test and release management.\n> \n> That isn't what I really wanted to do. As a one man band I was looking\n> to actually \"combine\" several repositories into one logical repository\n> to simplify commits, pushes, pulls to my own backup repositories.\n> I now see that that wasn't the purpose of submodule.\n> \n> Anyway, that is the perspective of this neophyte and I learned something\n> new which is a primary goal of mine.\n> \n> Finally, I'm back to my original question how to combine repositories? As\n> I said in my response to Alex, the multiple branches I got working but that\n> isn't what I want.\n> \n> What I think I now want is to create a new repository which contains my\n> other repositories as sub-directories (with their histories) after combining\n> them I would delete the old repositories. I expect the resulting history\n> to be sequential, with the sequence defined by the order I combine them,\n> but maybe there is another choice?\n\nAh, okay. I was assuming that you wanted them to maintain their original \nidentities (so you'd send stuff off for each of them separately, for \nexample).\n\nI think you can do what you want by doing:\n\n# Set up the new line:\n$ mkdir x; cd x\n$ git init\n$ touch README\n$ git add README\n$ git commit\n\n# Add a project \"foo\"\n$ git fetch ../foo refs/heads/master:refs/heads/foo\n$ git merge --no-commit foo\n$ git read-tree --reset -u HEAD\n$ git read-tree -u --prefix=foo/ foo\n$ git commit\n\nAnd repeat for all of the other projects.\n\nWhat's going on here is that you're merging in each project, except that \nyou're moving all of the files from that project into a subdirectory as \nyou pull in the content. The resulting repository has one recent dull \ninitial commit, and then merges in each of the other projects with their \nhistory, with only the slight oddity that they don't go back to the same \ninitial commit, and the merge renames all of the project's files.\n\nI think there may be a more obvious way of doing this (it's essentially \nhow gitweb and git-gui got into the git history), but I'm not sure what it \nis, if there is one.\n\n\t-Daniel\n*This .sig left intentionally blank*\n"},{"id":"62545","messageId":"475CDE73.9010505@saville.com","threadId":"11205","inReplyTo":"Pine.LNX.4.64.0712092130560.5349@iabervon.org","subject":"Re: How-to combine several separate git repos?","fromName":"Wink Saville","fromEmail":"wink@saville.com","sentAt":"2007-12-10T06:36:35Z","receivedAt":"2007-12-10T06:36:35Z","isPatch":false,"sender":{"key":"wink@saville.com","avatar":"https://avatars.githubusercontent.com/u/1024284?v=4"},"body":"Daniel Barkalow wrote:\n> On Sun, 9 Dec 2007, Wink Saville wrote:\n>\n>   \n> Ah, okay. I was assuming that you wanted them to maintain their original \n> identities (so you'd send stuff off for each of them separately, for \n> example).\n>\n> I think you can do what you want by doing:\n>\n> # Set up the new line:\n> $ mkdir x; cd x\n> $ git init\n> $ touch README\n> $ git add README\n> $ git commit\n>\n> # Add a project \"foo\"\n> $ git fetch ../foo refs/heads/master:refs/heads/foo\n> $ git merge --no-commit foo\n> $ git read-tree --reset -u HEAD\n> $ git read-tree -u --prefix=foo/ foo\n> $ git commit\n>\n> And repeat for all of the other projects.\n>\n> What's going on here is that you're merging in each project, except that \n> you're moving all of the files from that project into a subdirectory as \n> you pull in the content. The resulting repository has one recent dull \n> initial commit, and then merges in each of the other projects with their \n> history, with only the slight oddity that they don't go back to the same \n> initial commit, and the merge renames all of the project's files.\n>\n> I think there may be a more obvious way of doing this (it's essentially \n> how gitweb and git-gui got into the git history), but I'm not sure what it \n> is, if there is one.\n>\n> \t-Daniel\n> *This .sig left intentionally blank*\n>   \n\nDaniel,\n\nWorked like a charm, someday maybe I'll understand why it works:)\n\nWink\n"},{"id":"62547","messageId":"Pine.LNX.4.64.0712100137250.5349@iabervon.org","threadId":"11205","inReplyTo":"475CDE73.9010505@saville.com","subject":"Re: How-to combine several separate git repos?","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2007-12-10T06:51:32Z","receivedAt":"2007-12-10T06:51:32Z","isPatch":false,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Sun, 9 Dec 2007, Wink Saville wrote:\n\n> Daniel,\n> \n> Worked like a charm, someday maybe I'll understand why it works:)\n\nI should probably explain (now that I know it's actually relevant).\n\n> > # Add a project \"foo\"\n> > $ git fetch ../foo refs/heads/master:refs/heads/foo\n\nGet the history and data, as an extra branch, so we can deal with it \neasily.\n\n> > $ git merge --no-commit foo\n\nWe want to generate a merge commit, but we want to mess with it, so we use \nmerge to set it up, but --no-commit to not actually commit it. (The commit \nbelow will generate a merge commit if we don't cancel stuff entirely.)\n\n> > $ git read-tree --reset -u HEAD\n\nReplace the index (--reset), updating the working directory (-u), with \nHEAD (the commit on the local side before the merge we're in the middle \nof).\n\n> > $ git read-tree -u --prefix=foo/ foo\n\nRead into the index, updating the working directory, \"foo\" (the branch we \nfetched above), but with the prefix \"foo/\" so everything is stuffed into a \nsubdirectory.\n\n> > $ git commit\n\nAnd commit the result, which has the tree as constructed above (everything \nfrom the local parent, and everything from the branch in a subdirectory), \nand has the parents as for the merge we started: first parent is the local \nline without the additional branch, and the second parent is the added \nrepository.\n\nAnd git doesn't care about global structure, so the fact that this commit \nis obviously just what you'd ideally like, while the history as a whole is \na bit odd (like, it doesn't have a unique start, and development didn't \nstart in subdirectories, and...) doesn't matter.\n\n\t-Daniel\n*This .sig left intentionally blank*\n"},{"id":"62548","messageId":"475CE457.2050207@saville.com","threadId":"11205","inReplyTo":"Pine.LNX.4.64.0712100137250.5349@iabervon.org","subject":"Re: How-to combine several separate git repos?","fromName":"Wink Saville","fromEmail":"wink@saville.com","sentAt":"2007-12-10T07:01:43Z","receivedAt":"2007-12-10T07:01:43Z","isPatch":false,"sender":{"key":"wink@saville.com","avatar":"https://avatars.githubusercontent.com/u/1024284?v=4"},"body":"Daniel Barkalow wrote:\n> On Sun, 9 Dec 2007, Wink Saville wrote:\n>\n>   \nThe history does look odd as I look at in gitk, but\nit is there and I've expanded my knowledge a little.\n\nThanks again,\n\nWink\n"},{"id":"62552","messageId":"20071210075231.GA2984@steel.home","threadId":"11205","inReplyTo":"475C3E25.30704@saville.com","subject":"Re: How-to combine several separate git repos?","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-12-10T07:52:31Z","receivedAt":"2007-12-10T07:52:31Z","isPatch":false,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Wink Saville, Sun, Dec 09, 2007 20:12:37 +0100:\n>> You can merge them, for example:\n>>\n>>     $ cd project1\n>>     $ git merge project2/master\n>>   \n> Starting over (restoring the original from a tar backup)\n> this didn't work I get:\n>\n> wink@ic2d1:$ cd StateMachine\n> wink@ic2d1:$ git merge ../test2/master\n> ../test2/master - not something we can merge\n\nThis is *not* what I suggested. It should be:\n\n    $ git config ... (as suggested before)\n    $ git fetch test2\n    $ git merge test2/master\n\nHere test2/master - is *NOT* a path. It is the name of the branch\nwhere the local repository stores reference to the commit\ncorresponding to the master of remote repo (that is: the \"master\"\nbranch of \"test2\", as seen from the repository where you do the\nmerge).\n\n> So the first suggestion works, but I don't want them as\n> separate branches as I want to work on the simultaneously\n> and they'll share common code.\n\nSound like the secode (merge) approach\n\n> Another option I was thinking would work for me would be to use\n> submodules. But I'm not sure submodules are ready for\n> neophytes and maybe it doesn't do what I want?\n\nThey are ready for some (dunno if they'd like to be called neophytes).\nI just don't think you need them (keywords on your explanations being\n\"share common code\", understanding them as \"the modules use the common\ncode simultaneously\").\n"},{"id":"62603","messageId":"475D7D83.1050509@saville.com","threadId":"11205","inReplyTo":"20071210075231.GA2984@steel.home","subject":"Re: How-to combine several separate git repos?","fromName":"Wink Saville","fromEmail":"wink@saville.com","sentAt":"2007-12-10T17:55:15Z","receivedAt":"2007-12-10T17:55:15Z","isPatch":false,"sender":{"key":"wink@saville.com","avatar":"https://avatars.githubusercontent.com/u/1024284?v=4"},"body":"Alex Riesen wrote:\n> Wink Saville, Sun, Dec 09, 2007 20:12:37 +0100:\n>   \n> <snip>\nThanks it was my mistake,\n\nWink\n"}]}