{"thread":{"id":"19981","subject":"git svn and multiple cloned repositories","startedAt":"2009-06-30T12:23:30Z","lastAt":"2009-06-30T13:44:28Z","messageCount":2,"participants":["Bruno Harbulot","Peter Harris"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"117230","messageId":"h2d043$4tm$1@ger.gmane.org","threadId":"19981","inReplyTo":null,"subject":"git svn and multiple cloned repositories","fromName":"Bruno Harbulot","fromEmail":"bruno.harbulot@manchester.ac.uk","sentAt":"2009-06-30T12:23:30Z","receivedAt":"2009-06-30T12:23:30Z","isPatch":false,"sender":{"key":"bruno.harbulot@manchester.ac.uk","avatar":null},"body":"Hello,\n\n\nI participate in a few open-source projects for which I provide patches \nsometimes, but most of these projects use Subversion. git-svn is very \nconvenient for trying out patches without interfering with the main \nbranch (so as to submit them when they're ready). I presume many 'git \nsvn' users do something like this too.\n\nHowever, I'd like to keep multiple copies of this repository (on a few \nmachines, including one on a backup server) with the appropriate SVN \nmetadata. I'd also like to be able to do 'git svn fetch' on only one of \nthese cloned repositories (perhaps via crontab on the server) and to be \nable to push/pull this SVN metadata along with the commits between the \ncloned git repositories.\n\n\nIs there a recommended way to do this?\n\n\nI have found 3 ways of achieving this, but none of them seem ideal:\n\n1. Copying the entire cloned repository as regular files and doing 'git \nsvn fetch' regularly on each copy.\n\n    - Doing the initial \"git svn clone\" on one machine (machine1).\n    - Copying the cloned repository onto the backup machine \n(backup-server), using tar for example.\n    - Adding the repository on 'backup-server' as a remote repository on \n'machine1' (so that I can push my own branches).\n    - Doing 'git svn fetch' regularly on both 'machine1' and \n'backup-server'.\n\nThis works, but this duplicates the interactions with the SVN server \n(for as many clones I have locally). This is what I'd like to avoid.\n\n\n2. Transferring the SVN references by hand.\n\n    - On 'backup-server':\n      - git --bare init\n      - git --bare svn init -s --prefix=svn/ https://project.example.com/svn\n      - git --bare svn fetch\n    - On 'machineX':\n      - git clone ssh://backup-server/~/Project.git/\n      - ssh backup-server \"cd Project.git ; tar czf - svn refs/remotes \ninfo/refs packed-refs\" | tar xvzf - -C .git/\n      - Edit packed-refs to change \"refs/heads/master\" into \n\"refs/remotes/origin/master\".\n      - git svn init -s --prefix=svn/ https://project.example.com/svn\n      - git svn fetch\n\n\n3. Using 'git clone --mirror' (only works with --bare option).\n\n(same as 2. on backup-server)\n    - git clone --mirror ssh://backup-server/~/Project.git\n    - mv Project.git .git\n    - Edit .git/config by hand to remove the bare repository option\n    - git svn init -s --prefix=svn/ https://project.example.com/svn\n    - git svn fetch\n(I sill have to use 'git svn fetch' regularly with this).\n\n\n\n\nBest wishes,\n\nBruno.\n"},{"id":"117234","messageId":"eaa105840906300644s6bc9b619i24bd54537f4a67d4@mail.gmail.com","threadId":"19981","inReplyTo":"h2d043$4tm$1@ger.gmane.org","subject":"Re: git svn and multiple cloned repositories","fromName":"Peter Harris","fromEmail":"git@peter.is-a-geek.org","sentAt":"2009-06-30T13:44:28Z","receivedAt":"2009-06-30T13:44:28Z","isPatch":false,"sender":{"key":"git@peter.is-a-geek.org","avatar":null},"body":"On Tue, Jun 30, 2009 at 8:23 AM, Bruno Harbulot wrote:\n> I participate in a few open-source projects for which I provide patches\n> sometimes, but most of these projects use Subversion. git-svn is very\n> convenient for trying out patches without interfering with the main branch\n> (so as to submit them when they're ready). I presume many 'git svn' users do\n> something like this too.\n>\n> However, I'd like to keep multiple copies of this repository (on a few\n> machines, including one on a backup server) with the appropriate SVN\n> metadata. I'd also like to be able to do 'git svn fetch' on only one of\n> these cloned repositories (perhaps via crontab on the server) and to be able\n> to push/pull this SVN metadata along with the commits between the cloned git\n> repositories.\n>\n>\n> Is there a recommended way to do this?\n>\n>\n> I have found 3 ways of achieving this, but none of them seem ideal:\n>\n> 1. Copying the entire cloned repository as regular files and doing 'git svn\n> fetch' regularly on each copy.\n\n> 2. Transferring the SVN references by hand.\n\n> 3. Using 'git clone --mirror' (only works with --bare option).\n\nI use 4. Set up git remotes by hand to populate svn remotes directly.\n\n  - On 'backup-server':\ngit svn clone -s svn://upstream/project\ncrontab -e  # run git svn fetch periodically\n\n  - On 'machineX':\nmkdir project\ncd project\ngit init\ngit remote add origin git://mirror/project\ngit config --add remote.origin.fetch refs/remotes/*:refs/remotes/*\ngit fetch\ngit svn init -s svn://upstream/project\ngit reset --hard trunk\ngit svn rebase\n\nPeter Harris\n"}]}