{"thread":{"id":"25337","subject":"git svn project shuffle","startedAt":"2010-10-04T18:36:36Z","lastAt":"2010-10-15T16:48:11Z","messageCount":4,"participants":["Christopher Snapp","Jonathan Nieder"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"152565","messageId":"AANLkTimL18WHOrLjA5iWNcsgd6H8Eeq19LfJNjkKu_b-@mail.gmail.com","threadId":"25337","inReplyTo":null,"subject":"git svn project shuffle","fromName":"Christopher Snapp","fromEmail":"snappca@gmail.com","sentAt":"2010-10-04T18:36:36Z","receivedAt":"2010-10-04T18:36:36Z","isPatch":false,"sender":{"key":"snappca@gmail.com","avatar":null},"body":"I have used git to interface with an svn repo for some time quite\nsuccessfully, but today I've run into a scenario that I'm not sure how\nto solve.\n\nThe situation is this:\n* I have a project (let's call it \"oldproj\") that has its own\nbranches, tags, and trunk svn structure\n* oldproj is checked out using git svn clone --stdlayout and all has been swell\n* due to a CM shuffle oldproj's svn trunk has been copied to a new svn\nproject (let's call it newproj), so oldproj/trunk has been copied to\nnewproj/trunk/oldproj\n* oldproj's branches and tags directories have been \"archived\",\nmeaning it isn't CM guy's intention to bring them over to the newproj\nstructure.  I don't mind losing the contents of the oldproj's branches\nand tags, but I'm not sure how to transition to newproj using my\nalready checked out git svn clone\n\nMy questions are:\n# If I try to start from scratch by using git svn clone --stdlayout\nthe \"newproj\" location I lose all of the revision history associated\nwith \"oldproj/trunk\" that has been copied to newproj/trunk/oldproj.\nHow can I have git understand the history for the\nnewproj/trunk/oldproj location?\n\n# An alternative would be if I could somehow reconfigure my already\nchecked out oldproj git repo so I retain all of the version history\nand my local branches and can move forward checking code into the\nnewproj/trunk/oldproj location?\n\nRegarding the second question, I'd be concerned that the loss of the\nbranches and tags from the oldproj would confuse things in the future\nas the newproj branches and tags are new.\n\nThis is probably a simple scenario that many have bumped into but my\nsearches have so far come up blank.\n\nThanks very much for any guidance or pointers to previous discussions\nregarding this scenario.\n\n--\nChris\n"},{"id":"152570","messageId":"20101004185424.GA6343@burratino","threadId":"25337","inReplyTo":"AANLkTimL18WHOrLjA5iWNcsgd6H8Eeq19LfJNjkKu_b-@mail.gmail.com","subject":"Re: git svn project shuffle","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-10-04T18:54:24Z","receivedAt":"2010-10-04T18:54:24Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi Chris,\n\nChristopher Snapp wrote:\n\n> # If I try to start from scratch by using git svn clone --stdlayout\n> the \"newproj\" location I lose all of the revision history associated\n> with \"oldproj/trunk\" that has been copied to newproj/trunk/oldproj.\n> How can I have git understand the history for the\n> newproj/trunk/oldproj location?\n\nIf I were in your situation I would do the following:\n\n 0. Make backups!\n 1. git svn init -Rnew ...newproj info...\n 2. Edit .git/config to put the new project in a separate\n     refs/remotes/newproj/ hierarchy.\n 3. git svn -Rnew fetch\n 4. gitk --all.  Look around.\n 5. For each \"tip\" of the old history:\n     git replace <corresponding new commit> <old branch tip>\n 6. gitk --all.  Make sure it looks right.\n 7. git filter-branch -- --all\n 8. rm -fr .git/svn.  This is destructive, but only of information\n    you're probably not using.  (It forgets old properties, for\n    example.)\n 9. Edit .git/config and use \"git branch -r -d\" to get rid of references\n    to oldproj.  Rename the newproj svn-remote to \"svn\" again.\n10. git svn fetch.\n11. gitk --all.  Everything good?  Push.\n\n> # An alternative would be if I could somehow reconfigure my already\n> checked out oldproj git repo so I retain all of the version history\n> and my local branches and can move forward checking code into the\n> newproj/trunk/oldproj location?\n\nIf your history in each branch is not published and is linear, you\ncould also try just putting the old and new histories in one temporary\nrepo and rebasing your private branches.\n\nOr you can export your own work with \"git format-patch\" or \"git\nfast-export\" and reimport it with \"git am\" or \"git fast-import\".\n\nHope that helps,\nJonathan\n"},{"id":"153402","messageId":"AANLkTimxbmk2u=4d1b1LS+GMp9ry__4TtEx5UMJPk4-5@mail.gmail.com","threadId":"25337","inReplyTo":"20101004185424.GA6343@burratino","subject":"Re: git svn project shuffle","fromName":"Christopher Snapp","fromEmail":"snappca@gmail.com","sentAt":"2010-10-13T13:41:35Z","receivedAt":"2010-10-13T13:41:35Z","isPatch":false,"sender":{"key":"snappca@gmail.com","avatar":null},"body":"Jonathan,\n\nFirst off, thanks very much for the quick and thorough response.\n\nSadly, this is outside the norm for me and I'm just not understanding\nall the steps.  As a result I've successfully mangled my poor git\nrepo. Good thing I followed step 0. :)\n\nI'll continue to read up on some of the steps you listed to try and\nfigure out where I went wrong, but I'm wondering if there might be an\neasier way to get back to a stable repo.  The alternative I'd like to\ntry is to simply clone the new svn location.  What I'm not\nunderstanding is why git will not traverse the svn history properly.\nIf you remember my old project's trunk has been copied to a\nsubdirectory of the new project's trunk.  So, oldproj/trunk is now\nnewproj/trunk/oldproj.  When I do a git svn clone of the newproj I\nwould expect it to follow the svn copy that created\nnewproj/trunk/oldproj but it doesn't.  I'm simply left with a couple\nof commits and none of the original oldproj history.  If I view the\nsvn repo using some other tool (e.g. kdesvn) I can see all the history\nas expected.  I'm not coming up with anything in my searches that\nwould give me a reason why git would stop searching history.\n\nThanks again for the help,\n\n\n\n\nOn Mon, Oct 4, 2010 at 2:54 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> Hi Chris,\n>\n> Christopher Snapp wrote:\n>\n>> # If I try to start from scratch by using git svn clone --stdlayout\n>> the \"newproj\" location I lose all of the revision history associated\n>> with \"oldproj/trunk\" that has been copied to newproj/trunk/oldproj.\n>> How can I have git understand the history for the\n>> newproj/trunk/oldproj location?\n>\n> If I were in your situation I would do the following:\n>\n>  0. Make backups!\n>  1. git svn init -Rnew ...newproj info...\n>  2. Edit .git/config to put the new project in a separate\n>     refs/remotes/newproj/ hierarchy.\n>  3. git svn -Rnew fetch\n>  4. gitk --all.  Look around.\n>  5. For each \"tip\" of the old history:\n>     git replace <corresponding new commit> <old branch tip>\n>  6. gitk --all.  Make sure it looks right.\n>  7. git filter-branch -- --all\n>  8. rm -fr .git/svn.  This is destructive, but only of information\n>    you're probably not using.  (It forgets old properties, for\n>    example.)\n>  9. Edit .git/config and use \"git branch -r -d\" to get rid of references\n>    to oldproj.  Rename the newproj svn-remote to \"svn\" again.\n> 10. git svn fetch.\n> 11. gitk --all.  Everything good?  Push.\n>\n>> # An alternative would be if I could somehow reconfigure my already\n>> checked out oldproj git repo so I retain all of the version history\n>> and my local branches and can move forward checking code into the\n>> newproj/trunk/oldproj location?\n>\n> If your history in each branch is not published and is linear, you\n> could also try just putting the old and new histories in one temporary\n> repo and rebasing your private branches.\n>\n> Or you can export your own work with \"git format-patch\" or \"git\n> fast-export\" and reimport it with \"git am\" or \"git fast-import\".\n>\n> Hope that helps,\n> Jonathan\n>\n\n\n\n-- \nChris\n"},{"id":"153589","messageId":"20101015164811.GA10204@burratino","threadId":"25337","inReplyTo":"AANLkTimxbmk2u=4d1b1LS+GMp9ry__4TtEx5UMJPk4-5@mail.gmail.com","subject":"Re: git svn project shuffle","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-10-15T16:48:11Z","receivedAt":"2010-10-15T16:48:11Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Hi again,\n\nChristopher Snapp wrote:\n\n> If you remember my old project's trunk has been copied to a\n> subdirectory of the new project's trunk.  So, oldproj/trunk is now\n> newproj/trunk/oldproj.\n\nYeah, I was ignoring this part. :)  git svn is not really wired for\nit.\n\nThe instructions were meant to also be usable in a case where oldproj\nand newproj are entirely independent repositories.\n\n> When I do a git svn clone of the newproj I\n> would expect it to follow the svn copy that created\n> newproj/trunk/oldproj but it doesn't.\n\nIf the layout has been relatively stable before, maybe \"git svn\n--no-follow-parent\" would give some joy.\n\nStill I would be interested in hearing where the grafting procedure\nwent wrong.  If you end up tracking it down to a single step, do\nplease let us know.\n\nRegards,\nJonathan\n"}]}