{"thread":{"id":"13538","subject":"Migrating a git repository to subversion","startedAt":"2008-05-15T23:08:52Z","lastAt":"2008-05-16T17:45:35Z","messageCount":7,"participants":["Alf Mikula","Avery Pennarun","Björn Steinbrink","Linus Torvalds","Martin Langhoff","Imran M Yousuf"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"77082","messageId":"42dc968d0805151608q2ed89fc8madcd8d341a4ed1df@mail.gmail.com","threadId":"13538","inReplyTo":null,"subject":"Migrating a git repository to subversion","fromName":"Alf Mikula","fromEmail":"amikula@gmail.com","sentAt":"2008-05-15T23:08:52Z","receivedAt":"2008-05-15T23:08:52Z","isPatch":false,"sender":{"key":"amikula@gmail.com","avatar":null},"body":"I'm a relatively new (2 weeks) user of Git, and so far I really love\nit, and I want to educate my co-workers about it.\n\nHaving said that, I want to demonstrate git's git<--->svn\ncapabilities, and currently everybody here has and understands\nSubversion.  So, I want to initialize a Subversion repository with my\ngit history from my local git repository.  Here's what I tried:\n\n1. Create a new, empty subversion project with trunk/tags/branches subdirs.\n2. git svn clone http://myhost.com/path/to/project --stdlayout\n3. git pull ../git_project\n4. git svn dcommit\n\n\nThis put all my files into Subversion, but under a single commit.  Is\nthere a step I'm missing that would allow git to commit all my\nindividual git commits to the Subversion repository?  I've done a\nbunch of searches, but all the docs seem to focus on cloning an\nexisting svn repository, as opposed to exporting git repositories to\nSubversion.\n\nThanks in advance,\n\n-Alf\n"},{"id":"77083","messageId":"32541b130805151619y7dcb3812i1440ebbb0def98ad@mail.gmail.com","threadId":"13538","inReplyTo":"42dc968d0805151608q2ed89fc8madcd8d341a4ed1df@mail.gmail.com","subject":"Re: Migrating a git repository to subversion","fromName":"Avery Pennarun","fromEmail":"apenwarr@gmail.com","sentAt":"2008-05-15T23:19:13Z","receivedAt":"2008-05-15T23:19:13Z","isPatch":false,"sender":{"key":"apenwarr@gmail.com","avatar":"https://avatars.githubusercontent.com/u/20592?v=4"},"body":"On 5/15/08, Alf Mikula <amikula@gmail.com> wrote:\n>  1. Create a new, empty subversion project with trunk/tags/branches subdirs.\n>  2. git svn clone http://myhost.com/path/to/project --stdlayout\n>  3. git pull ../git_project\n>  4. git svn dcommit\n>\n>  This put all my files into Subversion, but under a single commit. [...]\n\nStep 3 created a \"merge commit\", which connected the (presumably, but\nnot necessarily, empty) repository from step 2 to the other one in\nstep 3.  git-svn doesn't know how to break apart a merge into its\nparts (mostly because it's theoretically impossible to do in the\ngeneral case :)) so it just makes a single svn commit.\n\nThe way people usually deal with this when using git-svn is they use\n\"git rebase\" to simplify their history and eliminate the need for\nmerge commits.  This makes git-svn much happier, but unfortunately\nmakes future git merging a bit more complicated.\n\nAnyway, to answer your question: add a new step 3.5 that's something like:\n\n  git rebase WHATEVER\n\nWhere WHATEVER is the name of the last commit git-svn created in step 2.\n\nHave fun,\n\nAvery\n"},{"id":"77087","messageId":"20080515234731.GA17897@atjola.homenet","threadId":"13538","inReplyTo":"32541b130805151619y7dcb3812i1440ebbb0def98ad@mail.gmail.com","subject":"Re: Migrating a git repository to subversion","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2008-05-15T23:47:31Z","receivedAt":"2008-05-15T23:47:31Z","isPatch":false,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2008.05.15 19:19:13 -0400, Avery Pennarun wrote:\n> On 5/15/08, Alf Mikula <amikula@gmail.com> wrote:\n> >  1. Create a new, empty subversion project with trunk/tags/branches subdirs.\n> >  2. git svn clone http://myhost.com/path/to/project --stdlayout\n> >  3. git pull ../git_project\n> >  4. git svn dcommit\n> >\n> >  This put all my files into Subversion, but under a single commit. [...]\n> \n> Step 3 created a \"merge commit\", which connected the (presumably, but\n> not necessarily, empty) repository from step 2 to the other one in\n> step 3.  git-svn doesn't know how to break apart a merge into its\n> parts (mostly because it's theoretically impossible to do in the\n> general case :)) so it just makes a single svn commit.\n> \n> The way people usually deal with this when using git-svn is they use\n> \"git rebase\" to simplify their history and eliminate the need for\n> merge commits.  This makes git-svn much happier, but unfortunately\n> makes future git merging a bit more complicated.\n> \n> Anyway, to answer your question: add a new step 3.5 that's something like:\n> \n>   git rebase WHATEVER\n> \n> Where WHATEVER is the name of the last commit git-svn created in step 2.\n\nIn this case, \"git svn rebase\" handles figuring out what WHATEVER should\nbe. That said, I'd suggest something different/bigger to show off git's\npower. Creating a linear history is not really impressive, especially\nwhen you go on and compare the svn and git repos afterwards.\n\nI'd create a svn repo with trunk, tags, branches like you have done,\nimport that via git-svn. Then add a few commits to trunk, dcommit them.\nThen create a branch in _svn_ [1]. Use \"git svn fetch\" to get that into\nyour git repo, do some commits on that branch, dcommit them, do some\ncommits on trunk, dcommit them. Then checkout trunk, merge the other\nbranch, and dcommit the result. Then repeat that, so you got two merges\non trunk.\n\nIf you then look at your history in gitk (for example), you'll see the\nmerges just fine, while the svn history has no clue about it, except for\nthe commit message. If you do that \"live\", you can also show off the\nhistory after the first merge, and show that the second merge needs no\ncrappy -r123:154 option to figure out what exactly needs to be merged\nlike svn does, because git actually records merges.\n\nThe results on the svn side of things are the same as if you had done\nthe merges there, and being able to compare that quite directly to how\ngit does it is nice.\n\nBjörn\n\n[1] Here's a small script that creates a branch in the svn repo (using\nthe svn executable) from the most recent svn commit that is in your\ncurrent git branch (yeah, it's rather ugly):\n\n#!/bin/sh\nif test \"$1\" = ''\nthen\n\techo \"Usage: git-svn-branch <branch_name>\"\n\texit 127\nfi\n\nCURRENT=$(git rev-list --first-parent --pretty=format:%b HEAD | grep -m1 -o 'git-svn-id: [^ ]*' | sed -e 's/git-svn-id: //')\n\nSRC=${CURRENT%@*}\nREV=${CURRENT#*@}\nURL=$(git config --get svn-remote.svn.url)\n\nURL=$(echo -n \"$URL\" | sed -e 's!//.*@!//!')\nDST=\"$URL/$(git config --get svn-remote.svn.branches | grep -o '^[^:]*' | sed -e \"s/\\*/$1/\")\"\n\nsvn cp -r \"$REV\" \"$SRC\" \"$DST\" -m \"Create branch $1\"\n"},{"id":"77095","messageId":"alpine.LFD.1.10.0805151952260.2941@woody.linux-foundation.org","threadId":"13538","inReplyTo":"42dc968d0805151608q2ed89fc8madcd8d341a4ed1df@mail.gmail.com","subject":"Re: Migrating a git repository to subversion","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2008-05-16T03:01:01Z","receivedAt":"2008-05-16T03:01:01Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Thu, 15 May 2008, Alf Mikula wrote:\n> \n> Having said that, I want to demonstrate git's git<--->svn\n> capabilities, and currently everybody here has and understands\n> Subversion.  So, I want to initialize a Subversion repository with my\n> git history from my local git repository.  Here's what I tried:\n\nHmm. I don't think there is any git2svn thing, but if your history is \nlinear (which is really the only thing SVN can handle, since SVN doesn't \nreally do \"merges\" in the git sense at all), you could just write some \nsilly script to extract the patches one by one and commit them using SVN.\n\nOr use \"tailor\", which should be able to convert from pretty much anything \ninto pretty much anything (again, assuming it's linear).\n\nOr, and this gets extra points for being disgusting, use \"git-cvsserver\" \nto serve a remote CVS repo, then cvssuck to create a local CVS repo out of \nit, and then do cvs2svn to create a SVN repo. Ta-daa!\n\n(Ok, that last one really is too ugly to live, but if it works, it really \nsounds like the true rube-goldberg way to do it, and should be done just \nbecause it is there, to paraphrase George Mallory).\n\n\t\t\tLinus\n"},{"id":"77096","messageId":"46a038f90805152053n43add2cbj8383c475772c3681@mail.gmail.com","threadId":"13538","inReplyTo":"alpine.LFD.1.10.0805151952260.2941@woody.linux-foundation.org","subject":"Re: Migrating a git repository to subversion","fromName":"Martin Langhoff","fromEmail":"martin.langhoff@gmail.com","sentAt":"2008-05-16T03:53:08Z","receivedAt":"2008-05-16T03:53:08Z","isPatch":false,"sender":{"key":"martin.langhoff@gmail.com","avatar":"https://gravatar.com/avatar/1e3f311b6c4c15836501901ca58f8c0b0667246488084ba524d8bc9867e22fd9?d=mp&s=160"},"body":"On Fri, May 16, 2008 at 3:01 PM, Linus Torvalds\n<torvalds@linux-foundation.org> wrote:\n> On Thu, 15 May 2008, Alf Mikula wrote:\n>> Having said that, I want to demonstrate git's git<--->svn\n>> capabilities, and currently everybody here has and understands\n>> Subversion.  So, I want to initialize a Subversion repository with my\n>> git history from my local git repository.  Here's what I tried:\n>\n> Hmm. I don't think there is any git2svn thing, but if your history is\n> linear (which is really the only thing SVN can handle, since SVN doesn't\n> really do \"merges\" in the git sense at all), you could just write some\n> silly script to extract the patches one by one and commit them using SVN.\n\nThe git svn rebase trick described earlier does almost exactly what Alf wants.\n\n> Or, and this gets extra points for being disgusting, use \"git-cvsserver\"\n> to serve a remote CVS repo, then cvssuck to create a local CVS repo out of\n> it, and then do cvs2svn to create a SVN repo. Ta-daa!\n\nUgh. Evil man.\n\n\n\nm\n-- \n martin.langhoff@gmail.com\n martin@laptop.org -- School Server Architect\n - ask interesting questions\n - don't get distracted with shiny stuff - working code first\n - http://wiki.laptop.org/go/User:Martinlanghoff\n"},{"id":"77100","messageId":"7bfdc29a0805152159l52a300e4rc1da3fe61db60fdc@mail.gmail.com","threadId":"13538","inReplyTo":"42dc968d0805151608q2ed89fc8madcd8d341a4ed1df@mail.gmail.com","subject":"Re: Migrating a git repository to subversion","fromName":"Imran M Yousuf","fromEmail":"imyousuf@gmail.com","sentAt":"2008-05-16T04:59:22Z","receivedAt":"2008-05-16T04:59:22Z","isPatch":false,"sender":{"key":"imyousuf@gmail.com","avatar":"https://gravatar.com/avatar/fda3c870262849d03c7b9c4d288842e128d6d80769fa7bc2d22731b7597928be?d=mp&s=160"},"body":"On Fri, May 16, 2008 at 5:08 AM, Alf Mikula <amikula@gmail.com> wrote:\n> I'm a relatively new (2 weeks) user of Git, and so far I really love\n>  it, and I want to educate my co-workers about it.\n>\n>  Having said that, I want to demonstrate git's git<--->svn\n>  capabilities, and currently everybody here has and understands\n>  Subversion.  So, I want to initialize a Subversion repository with my\n>  git history from my local git repository.  Here's what I tried:\n>\n>  1. Create a new, empty subversion project with trunk/tags/branches subdirs.\n>  2. git svn clone http://myhost.com/path/to/project --stdlayout\n\nI would just create another local branch and merge the tracking branch\ninto it, then rebase the branch with the master branch and then do the\nsvn dcommit. If the 'git svn clone' 'd repo is bare I think it should\ncommit the individual commits.\n\nBest regards,\n\nImran\n\n>  3. git pull ../git_project\n>  4. git svn dcommit\n>\n>\n>  This put all my files into Subversion, but under a single commit.  Is\n>  there a step I'm missing that would allow git to commit all my\n>  individual git commits to the Subversion repository?  I've done a\n>  bunch of searches, but all the docs seem to focus on cloning an\n>  existing svn repository, as opposed to exporting git repositories to\n>  Subversion.\n>\n>  Thanks in advance,\n>\n>  -Alf\n>  --\n>  To unsubscribe from this list: send the line \"unsubscribe git\" in\n>  the body of a message to majordomo@vger.kernel.org\n>  More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>\n\n\n\n-- \nImran M Yousuf\nEntrepreneur & Software Engineer\nSmart IT Engineering\nDhaka, Bangladesh\nEmail: imran@smartitengineering.com\nMobile: +880-1711402557\n"},{"id":"77152","messageId":"42dc968d0805161045g1b128360ha45e8bdf9ced6fe6@mail.gmail.com","threadId":"13538","inReplyTo":"46a038f90805152053n43add2cbj8383c475772c3681@mail.gmail.com","subject":"Re: Migrating a git repository to subversion","fromName":"Alf Mikula","fromEmail":"amikula@gmail.com","sentAt":"2008-05-16T17:45:35Z","receivedAt":"2008-05-16T17:45:35Z","isPatch":false,"sender":{"key":"amikula@gmail.com","avatar":null},"body":"> The git svn rebase trick described earlier does almost exactly what Alf wants.\n\nYou're absolutely right.  With the rebase, I have my history (which so\nfar is linear) in the SVN repository, and I can continue using git\nlocally and pushing my commits back to Subversion.  I also want to try\nBjörn's suggestions about merging SVN branches.  While Subversion\nfixed the most annoying problems in CVS, I think it got a lot of\nbranching, merging, and tagging wrong.  Maybe using git to handle\nmerging will make a nice band-aid.\n\nAnyway, thanks to all for the suggestions!\n\n-Alf\n"}]}