{"thread":{"id":"16839","subject":"Merge two repos with history included? (was Re: How do I..?)","startedAt":"2008-12-22T22:04:06Z","lastAt":"2008-12-23T07:58:01Z","messageCount":3,"participants":["Dylan Martin","Miklos Vajna","Alexander Gavrilov"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"98564","messageId":"e1a4c7f60812221404k57a5e150kac74f53c784b6b4a@mail.gmail.com","threadId":"16839","inReplyTo":null,"subject":"Merge two repos with history included? (was Re: How do I..?)","fromName":"Dylan Martin","fromEmail":"dmartin@sccd.ctc.edu","sentAt":"2008-12-22T22:04:06Z","receivedAt":"2008-12-22T22:04:06Z","isPatch":false,"sender":{"key":"dmartin@sccd.ctc.edu","avatar":null},"body":"I tried converting an existing SVN repo to git and then adding it to\nmy main git repo using the subtree merge technique described at\nhttp://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-subtree.html.\n I now have the various files in my repo, but they have no history.\nI checked, and my initial SVN to git conversion does contain history.\n\nI'm trying to add an exising repo as a subdir of my main repo with\nhistory included.  Can anyone tell me how to do that?\n\nI'm sorry if I'm phrasing my question badly, or if I'm asking\nsomething that should be obvious...\n\nThanks!\n-Dylan\n\nOn Wed, Dec 17, 2008 at 3:49 PM, Miklos Vajna <vmiklos@frugalware.org> wrote:\n> On Wed, Dec 17, 2008 at 03:16:59PM -0800, Dylan Martin <dmartin@sccd.ctc.edu> wrote:\n>> Sorry if this is a dumb question.  I've poked around the docs and\n>> tried the google searches I could think of, but I don't even know what\n>> kind of search terms one would use in trying to answer this.\n>>\n>> I'm a sysadmin and I've got a big monolithic git repo of all my\n>> scripts, documents, etc...  It used to be a CVS repo but I converted\n>> it to git a while ago.\n>> Before I switched to git, I played around with SVN a bit, and started\n>> a few tiny SVN repos for various scripts I was working on.  So, I know\n>> have one git repo with %90 of my stuff and a handful of SVN repos.\n>> I'd like to be able to add the SVN repos as subdirectories inside my\n>> git repo.  I've found lots of pages describing how to convert an SVN\n>> repo into a _new_ git repo, but I haven't found anything yet about\n>> importing the contents of an SVN repo as a subdirectory of an\n>> _existing_ git repo.\n>\n> I would convert each repo to git, then merge them using subtree merge.\n> See Documentation/howto/using-merge-subtree.txt.\n>\n"},{"id":"98585","messageId":"20081223004407.GZ21154@genesis.frugalware.org","threadId":"16839","inReplyTo":"e1a4c7f60812221404k57a5e150kac74f53c784b6b4a@mail.gmail.com","subject":"Re: Merge two repos with history included? (was Re: How do I..?)","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2008-12-23T00:44:07Z","receivedAt":"2008-12-23T00:44:07Z","isPatch":false,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Mon, Dec 22, 2008 at 02:04:06PM -0800, Dylan Martin <dmartin@sccd.ctc.edu> wrote:\n> I tried converting an existing SVN repo to git and then adding it to\n> my main git repo using the subtree merge technique described at\n> http://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-subtree.html.\n>  I now have the various files in my repo, but they have no history.\n\nThey have, but you are right about that - due to the nature of subtree\nmerge - git log <path> will show only the merge commits. (However git\nblame works fine, for example.)\n\n> I checked, and my initial SVN to git conversion does contain history.\n> \n> I'm trying to add an exising repo as a subdir of my main repo with\n> history included.  Can anyone tell me how to do that?\n\nI would try the following: Let's say you have super.git and foo.git, and\nyou want to merge foo.git to the subdirectory 'foo' of super.git. Then\nyou can do in foo.git:\n\nmkdir foo\nmv * foo\ngit add foo\ngit commit -a\n\nThen in super.git:\n\ngit pull path/to/foo.git master\n\nAnd then git log --follow should work just fine on any merged files as\nwell.\n"},{"id":"98591","messageId":"200812231058.02141.angavrilov@gmail.com","threadId":"16839","inReplyTo":"20081223004407.GZ21154@genesis.frugalware.org","subject":"Re: Merge two repos with history included? (was Re: How do I..?)","fromName":"Alexander Gavrilov","fromEmail":"angavrilov@gmail.com","sentAt":"2008-12-23T07:58:01Z","receivedAt":"2008-12-23T07:58:01Z","isPatch":false,"sender":{"key":"angavrilov@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42666?v=4"},"body":"On Tuesday 23 December 2008 03:44:07 Miklos Vajna wrote:\n> On Mon, Dec 22, 2008 at 02:04:06PM -0800, Dylan Martin <dmartin@sccd.ctc.edu> wrote:\n> > I checked, and my initial SVN to git conversion does contain history.\n> > \n> > I'm trying to add an exising repo as a subdir of my main repo with\n> > history included.  Can anyone tell me how to do that?\n> \n> I would try the following: Let's say you have super.git and foo.git, and\n> you want to merge foo.git to the subdirectory 'foo' of super.git. Then\n> you can do in foo.git:\n> \n> mkdir foo\n> mv * foo\n> git add foo\n> git commit -a\n> \n> Then in super.git:\n> \n> git pull path/to/foo.git master\n> \n> And then git log --follow should work just fine on any merged files as\n> well.\n> \n\n\nIf the conversion is one-shot, you can also try rewriting commits like this:\n\ncd foo.git\ngit filter-branch --commit-filter 'TREE=$1; shift; git commit-tree $(echo -e \"040000 tree $TREE\\tfoo\" | git mktree) \"$@\"' master\n\n(Maybe there is a simpler way, though)\n\nI used this once to merge together the history of a bunch of interrelated (and now dead) projects.\n\nAlexander\n"}]}