{"thread":{"id":"14915","subject":"Converting from svn to git","startedAt":"2008-08-10T13:11:43Z","lastAt":"2008-08-17T09:11:58Z","messageCount":8,"participants":["David Neu","Miklos Vajna","Michael J Gruber","Sam Vilain"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"86666","messageId":"e0b44a890808100611t27ddfcb6v21eecea89484c90b@mail.gmail.com","threadId":"14915","inReplyTo":null,"subject":"Converting from svn to git","fromName":"David Neu","fromEmail":"david@davidneu.com","sentAt":"2008-08-10T13:11:43Z","receivedAt":"2008-08-10T13:11:43Z","isPatch":false,"sender":{"key":"david@davidneu.com","avatar":null},"body":"Hi,\n\nI'm trying to move an svn repo to git.  I'm not going to be committing\nback to the svn repo, but will simply retire it and use git.\n\nThe issue I'm having is that the svn repo has sub directories that I'd\nlike to be separate git repos.\n\nI can easily accomplish this for the sub directories like this:\n\ngit-svn clone svn-url/subdir1\ngit-svn clone svn-url/subdir2\netc.\n\nbut for the files in the base directory\n\ngit-svn clone svn-url\n\npulls the entire directory tree.\n\nIs there a git-svn strategy similar to git-svnimport -P that would do the trick?\nMy git version 1.5.6.4 doesn't include git-svnimport, and I'm getting\nthe impression\nit's be deprecated.\n\nMany thanks for any help!\n\nCheers,\nDavid\n"},{"id":"86670","messageId":"20080810132409.GE18960@genesis.frugalware.org","threadId":"14915","inReplyTo":"e0b44a890808100611t27ddfcb6v21eecea89484c90b@mail.gmail.com","subject":"Re: Converting from svn to git","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2008-08-10T13:24:09Z","receivedAt":"2008-08-10T13:24:09Z","isPatch":false,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Sun, Aug 10, 2008 at 09:11:43AM -0400, David Neu <david@davidneu.com> wrote:\n> Is there a git-svn strategy similar to git-svnimport -P that would do the trick?\n> My git version 1.5.6.4 doesn't include git-svnimport, and I'm getting\n> the impression\n> it's be deprecated.\n\nSure, it is. Though if you _really_ need it, it's still under\n/contrib/examples.\n\nAnyway, if you do a single conversion, then probably speed does not\nmatter a lot; I would do a full import then use the subdirectory-filter\nof git filter-branch do drop everything outside the subdirectory.\n"},{"id":"86674","messageId":"e0b44a890808100754l536bc4f3kfd953b52044f6e59@mail.gmail.com","threadId":"14915","inReplyTo":"20080810132409.GE18960@genesis.frugalware.org","subject":"Re: Converting from svn to git","fromName":"David Neu","fromEmail":"david@davidneu.com","sentAt":"2008-08-10T14:54:59Z","receivedAt":"2008-08-10T14:54:59Z","isPatch":false,"sender":{"key":"david@davidneu.com","avatar":null},"body":"Thanks for the reply - this looks like what I'd need, but\nI can't see how to keep the contents of the base dir and\nlose the subdirs, e.g.\n\n$ git-filter-branch --subdirectory-filter . HEAD\n\nremoves all subdirs and the contents of the base dir.\n\nSo, I figure I'd remove each subdir, using\n\n$ git-filter-branch --tree-filter 'rm -rf subdir1/' HEAD\n\nbut this complains if subdir1 contains subdirectories, it\nsays: Namespace refs/original/ not empty\n\nMany thanks!\n\nCheers,\nDavid\n\n\nOn Sun, Aug 10, 2008 at 9:24 AM, Miklos Vajna <vmiklos@frugalware.org> wrote:\n>\n> On Sun, Aug 10, 2008 at 09:11:43AM -0400, David Neu <david@davidneu.com> wrote:\n> > Is there a git-svn strategy similar to git-svnimport -P that would do the trick?\n> > My git version 1.5.6.4 doesn't include git-svnimport, and I'm getting\n> > the impression\n> > it's be deprecated.\n>\n> Sure, it is. Though if you _really_ need it, it's still under\n> /contrib/examples.\n>\n> Anyway, if you do a single conversion, then probably speed does not\n> matter a lot; I would do a full import then use the subdirectory-filter\n> of git filter-branch do drop everything outside the subdirectory.\n"},{"id":"86680","messageId":"g7n1mk$67t$1@ger.gmane.org","threadId":"14915","inReplyTo":"e0b44a890808100754l536bc4f3kfd953b52044f6e59@mail.gmail.com","subject":"Re: Converting from svn to git","fromName":"Michael J Gruber","fromEmail":"michaeljgruber+gmane@fastmail.fm","sentAt":"2008-08-10T15:32:34Z","receivedAt":"2008-08-10T15:32:34Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"David Neu venit, vidit, dixit 10.08.2008 16:54:\n> Thanks for the reply - this looks like what I'd need, but\n> I can't see how to keep the contents of the base dir and\n> lose the subdirs, e.g.\n> \n> $ git-filter-branch --subdirectory-filter . HEAD\n> \n> removes all subdirs and the contents of the base dir.\n> \n> So, I figure I'd remove each subdir, using\n> \n> $ git-filter-branch --tree-filter 'rm -rf subdir1/' HEAD\n> \n> but this complains if subdir1 contains subdirectories, it\n> says: Namespace refs/original/ not empty\n\nIt complains because filter-branch stores the original refs in that \nnamespace, and on the second filter-branch run it wants to do this \nagain. You can avoid this by using the \"-f\" option to filter-branch, or \nby removing all subsirs in one go (\"rm -rf subdir1 subdir2...\"). Also, \nyou might want to rewrite all refs (\"--all\"), not just HEAD.\n\nMichael\n"},{"id":"86681","messageId":"e0b44a890808100848p367f5c66qfa21cba1b3ba12a0@mail.gmail.com","threadId":"14915","inReplyTo":"g7n1mk$67t$1@ger.gmane.org","subject":"Re: Converting from svn to git","fromName":"David Neu","fromEmail":"david@davidneu.com","sentAt":"2008-08-10T15:48:03Z","receivedAt":"2008-08-10T15:48:03Z","isPatch":false,"sender":{"key":"david@davidneu.com","avatar":null},"body":"That's great - thanks to everyone!\n\nOn Sun, Aug 10, 2008 at 11:32 AM, Michael J Gruber\n<michaeljgruber+gmane@fastmail.fm> wrote:\n> David Neu venit, vidit, dixit 10.08.2008 16:54:\n>>\n>> Thanks for the reply - this looks like what I'd need, but\n>> I can't see how to keep the contents of the base dir and\n>> lose the subdirs, e.g.\n>>\n>> $ git-filter-branch --subdirectory-filter . HEAD\n>>\n>> removes all subdirs and the contents of the base dir.\n>>\n>> So, I figure I'd remove each subdir, using\n>>\n>> $ git-filter-branch --tree-filter 'rm -rf subdir1/' HEAD\n>>\n>> but this complains if subdir1 contains subdirectories, it\n>> says: Namespace refs/original/ not empty\n>\n> It complains because filter-branch stores the original refs in that\n> namespace, and on the second filter-branch run it wants to do this again.\n> You can avoid this by using the \"-f\" option to filter-branch, or by removing\n> all subsirs in one go (\"rm -rf subdir1 subdir2...\"). Also, you might want to\n> rewrite all refs (\"--all\"), not just HEAD.\n>\n> Michael\n>\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"},{"id":"86799","messageId":"e0b44a890808111046q2626defdnab31b0d7b1c4578@mail.gmail.com","threadId":"14915","inReplyTo":"e0b44a890808100848p367f5c66qfa21cba1b3ba12a0@mail.gmail.com","subject":"Re: Converting from svn to git","fromName":"David Neu","fromEmail":"david@davidneu.com","sentAt":"2008-08-11T17:46:43Z","receivedAt":"2008-08-11T17:46:43Z","isPatch":false,"sender":{"key":"david@davidneu.com","avatar":null},"body":"OK, I did\n\n$ git-filter-branch --tree-filter 'rm -rf subdir1/ subdir2/ subdir3/' -- --all\n\nwhich looks good, except when I open gitk, I still see \"empty\" commits\nthat correspond to subdir1/, subdir2/ and subdir3/.\n\nIs there anyway to remove those?\n\nMany thanks!\n\nCheers,\nDavid\n\nOn Sun, Aug 10, 2008 at 11:48 AM, David Neu <david@davidneu.com> wrote:\n> That's great - thanks to everyone!\n>\n> On Sun, Aug 10, 2008 at 11:32 AM, Michael J Gruber\n> <michaeljgruber+gmane@fastmail.fm> wrote:\n>> David Neu venit, vidit, dixit 10.08.2008 16:54:\n>>>\n>>> Thanks for the reply - this looks like what I'd need, but\n>>> I can't see how to keep the contents of the base dir and\n>>> lose the subdirs, e.g.\n>>>\n>>> $ git-filter-branch --subdirectory-filter . HEAD\n>>>\n>>> removes all subdirs and the contents of the base dir.\n>>>\n>>> So, I figure I'd remove each subdir, using\n>>>\n>>> $ git-filter-branch --tree-filter 'rm -rf subdir1/' HEAD\n>>>\n>>> but this complains if subdir1 contains subdirectories, it\n>>> says: Namespace refs/original/ not empty\n>>\n>> It complains because filter-branch stores the original refs in that\n>> namespace, and on the second filter-branch run it wants to do this again.\n>> You can avoid this by using the \"-f\" option to filter-branch, or by removing\n>> all subsirs in one go (\"rm -rf subdir1 subdir2...\"). Also, you might want to\n>> rewrite all refs (\"--all\"), not just HEAD.\n>>\n>> Michael\n>>\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"},{"id":"87304","messageId":"g8421k$qcs$1@ger.gmane.org","threadId":"14915","inReplyTo":"e0b44a890808111046q2626defdnab31b0d7b1c4578@mail.gmail.com","subject":"Re: Converting from svn to git","fromName":"Michael J Gruber","fromEmail":"michaeljgruber+gmane@fastmail.fm","sentAt":"2008-08-15T13:58:11Z","receivedAt":"2008-08-15T13:58:11Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"David Neu venit, vidit, dixit 11.08.2008 19:46:\n> OK, I did\n> \n> $ git-filter-branch --tree-filter 'rm -rf subdir1/ subdir2/ subdir3/' -- --all\n> \n> which looks good, except when I open gitk, I still see \"empty\" commits\n> that correspond to subdir1/, subdir2/ and subdir3/.\n> \n> Is there anyway to remove those?\n\nA while ago I \"complained\" that rebase would skip empty commits. You \nmight experiment with that. Alternatively, the following works for me:\n\ngit filter-branch --commit-filter 'cmd=\"git commit-tree\"; test `git show \n--pretty=oneline $GIT_COMMIT|wc -l` = 1 && cmd=\"skip_commit\"; $cmd \"$@\"' \n-- --all\n\nThis skips all commits which introduce no diff. It will not remove \nbranches or tags which are related only to those subdirs.\n\nI am sure there will be more elegant ways to do that (esp. the test with \nwc).\n\nMichael\n"},{"id":"87422","messageId":"1218964318.2149.3.camel@maia.lan","threadId":"14915","inReplyTo":"g8421k$qcs$1@ger.gmane.org","subject":"Re: Converting from svn to git","fromName":"Sam Vilain","fromEmail":"sam@vilain.net","sentAt":"2008-08-17T09:11:58Z","receivedAt":"2008-08-17T09:11:58Z","isPatch":false,"sender":{"key":"sam@vilain.net","avatar":"https://gravatar.com/avatar/8fc840ca854dbf6f7065b4335e3b934951c1dca3b11db688e95e471901f8f4a8?d=mp&s=160"},"body":"On Fri, 2008-08-15 at 15:58 +0200, Michael J Gruber wrote:\n> A while ago I \"complained\" that rebase would skip empty commits. You \n> might experiment with that. Alternatively, the following works for me:\n> \n> git filter-branch --commit-filter 'cmd=\"git commit-tree\"; test `git show \n> --pretty=oneline $GIT_COMMIT|wc -l` = 1 && cmd=\"skip_commit\"; $cmd \"$@\"' \n> -- --all\n> \n> This skips all commits which introduce no diff. It will not remove \n> branches or tags which are related only to those subdirs.\n> \n> I am sure there will be more elegant ways to do that (esp. the test with \n> wc).\n\nsomething like this should work:\n\n  --commit-filter 'if [ \"$1\" = `git rev-parse HEAD^{tree}` ]; then\nskip_commit \"$@\"; else git commit-tree \"$@\"; fi'\n\nSam.\n"}]}