{"thread":{"id":"12899","subject":"Git and git-svn question.","startedAt":"2008-03-28T07:53:00Z","lastAt":"2008-03-28T14:38:25Z","messageCount":4,"participants":["Bosko Ivanisevic","Jean-Baptiste Quenot","Bob Cotton"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"73247","messageId":"47ECA3DC.8010901@sezampro.com","threadId":"12899","inReplyTo":null,"subject":"Git and git-svn question.","fromName":"Bosko Ivanisevic","fromEmail":"ivanisev@sezampro.com","sentAt":"2008-03-28T07:53:00Z","receivedAt":"2008-03-28T07:53:00Z","isPatch":false,"sender":{"key":"ivanisev@sezampro.com","avatar":null},"body":"My company uses SVN and I have to work on the code from two offices. \nSince SVN is far away from git in branching I've decided to set up git \nrepository as a mirror of company's SVN repo, which I would use as \nintermediate repository for my code:\n\ngit svn clone -t tags -b branches -T trunk \nsvn+ssh://company_server/path_to_svn_repo --prefix=company/\n\nSince I just started to use git I wonder if anyone can give me any hint\nwhat is the best way to accomplish following tasks with git:\n\n- In office 1 and office 2 I clone git repository that is a mirror of SVN:\n   git clone ssh://company_server/path_to_git_repo\n\n- I start new feature in office 1 based on the trunk version of SVN:\n   git checkout -b new-feature company/trunk\n\t\n- Work on this feature is not finished and, after few commits to the \nlocal 'new-feature' branch, I have to move to office 2.\n\n- From office 1 I push local branch 'new-feature' to the git repository \non company server.\n\n- In office 2 pull changes and continue to work on 'new-feature' branch \ncreated from office 1.\n\t\n- Commit everything in the git repository on company's server.\n\n- Finally commit everything to the SVN repository.\n"},{"id":"73248","messageId":"ae63f8b50803280427m55f6b957r12745c8e4178588b@mail.gmail.com","threadId":"12899","inReplyTo":"47ECA3DC.8010901@sezampro.com","subject":"Re: Git and git-svn question.","fromName":"Jean-Baptiste Quenot","fromEmail":"jbq@caraldi.com","sentAt":"2008-03-28T11:27:59Z","receivedAt":"2008-03-28T11:27:59Z","isPatch":false,"sender":{"key":"jbq@caraldi.com","avatar":null},"body":"Hi Bosko,\n\n2008/3/28, Bosko Ivanisevic <ivanisev@sezampro.com>:\n> My company uses SVN and I have to work on the code from two offices.\n>  Since SVN is far away from git in branching I've decided to set up git\n>  repository as a mirror of company's SVN repo, which I would use as\n>  intermediate repository for my code:\n>\n>  git svn clone -t tags -b branches -T trunk\n>  svn+ssh://company_server/path_to_svn_repo --prefix=company/\n\n-t tags -b branches -T trunk == -s\n\n>  Since I just started to use git I wonder if anyone can give me any hint\n>  what is the best way to accomplish following tasks with git:\n>\n>  - In office 1 and office 2 I clone git repository that is a mirror of SVN:\n>    git clone ssh://company_server/path_to_git_repo\n\nYou can't do that as SVN information is not cloned.  You have to call\ngit-svn clone on every working copy.\n\n>  - I start new feature in office 1 based on the trunk version of SVN:\n>    git checkout -b new-feature company/trunk\n>\n>  - Work on this feature is not finished and, after few commits to the\n>  local 'new-feature' branch, I have to move to office 2.\n>\n>  - From office 1 I push local branch 'new-feature' to the git repository\n>  on company server.\n>\n>  - In office 2 pull changes and continue to work on 'new-feature' branch\n>  created from office 1.\n>\n>  - Commit everything in the git repository on company's server.\n\n\nYes you'll need also a central Git repository to work with plain Git\nbranches between the offices.\n\n>  - Finally commit everything to the SVN repository.\n\nI suggest to use cherry-pick to propagate the changes from the feature\nbranch to the SVN-aware branch.\n\nAll the best,\n-- \nJean-Baptiste Quenot\nhttp://caraldi.com/jbq/blog/\n"},{"id":"73256","messageId":"47ECED8F.5050507@sezampro.com","threadId":"12899","inReplyTo":"ae63f8b50803280427m55f6b957r12745c8e4178588b@mail.gmail.com","subject":"Re: Git and git-svn question.","fromName":"Bosko Ivanisevic","fromEmail":"ivanisev@sezampro.com","sentAt":"2008-03-28T13:07:27Z","receivedAt":"2008-03-28T13:07:27Z","isPatch":false,"sender":{"key":"ivanisev@sezampro.com","avatar":null},"body":"Hi Jean\n\nJean-Baptiste Quenot wrote:\n> Hi Bosko,\n> \n> 2008/3/28, Bosko Ivanisevic <ivanisev@sezampro.com>:\n>> My company uses SVN and I have to work on the code from two offices.\n>>  Since SVN is far away from git in branching I've decided to set up git\n>>  repository as a mirror of company's SVN repo, which I would use as\n>>  intermediate repository for my code:\n>>\n>>  git svn clone -t tags -b branches -T trunk\n>>  svn+ssh://company_server/path_to_svn_repo --prefix=company/\n> \n> -t tags -b branches -T trunk == -s\n> \n>>  Since I just started to use git I wonder if anyone can give me any hint\n>>  what is the best way to accomplish following tasks with git:\n>>\n>>  - In office 1 and office 2 I clone git repository that is a mirror of SVN:\n>>    git clone ssh://company_server/path_to_git_repo\n> \n> You can't do that as SVN information is not cloned.  You have to call\n> git-svn clone on every working copy.\nI do not understand why I need to do this. I do not want to track SVN \nrepository in every working copy. When I create new branch in my working \ncopy with:\n\ngit checkout -b new-feature company/trunk\n\nthis branch should track refs/remotes/company/trunk from git repository \non the server and code at this point is completely synchronized with \ncode from SVN, since git repository on server is regularly updated \n(git-svn fetch is done on every commit in SVN). This is working without \nproblem. I guess that after\n\ngit pull\ngit rebase company/trunk\n\n(on local repository) I will get all new updates in the local git \nrepository in the working branch (which is new-feature), isn't it? Or \nmaybe I'm missing something.\n\nWhat I do not know is when I push changes made in local repository will \ngit actually push new branch with all changes and is it possible to use \nthat uploaded branch from the other place in order to continue work. If \nthat's the case is it possible, when work on new feature is finished, to \ndelete those branches in both local repositories and in \"central\" git \nrepository?\n\n> \n>>  - I start new feature in office 1 based on the trunk version of SVN:\n>>    git checkout -b new-feature company/trunk\n>>\n>>  - Work on this feature is not finished and, after few commits to the\n>>  local 'new-feature' branch, I have to move to office 2.\n>>\n>>  - From office 1 I push local branch 'new-feature' to the git repository\n>>  on company server.\n>>\n>>  - In office 2 pull changes and continue to work on 'new-feature' branch\n>>  created from office 1.\n>>\n>>  - Commit everything in the git repository on company's server.\n> \n> \n> Yes you'll need also a central Git repository to work with plain Git\n> branches between the offices.\n> \n>>  - Finally commit everything to the SVN repository.\n> \n> I suggest to use cherry-pick to propagate the changes from the feature\n> branch to the SVN-aware branch.\n> \n> All the best,\n\nRegarding commit to SVN I thought it is possible to do it from central \nrepository in the following way:\n\ngit checkout new-feature (to checkout branch I was working on from both \noffices)\ngit svn fetch (fetch all new changes from SVN)\ngit svn rebase (apply changes from SVN in the new-feature branch)\ngit svn dcommit (upload changes to the SVN)\n\nRegards,\nBosko Ivanisevic\n"},{"id":"73270","messageId":"m24paqsyla.fsf@rallydevelopment.com","threadId":"12899","inReplyTo":"ae63f8b50803280427m55f6b957r12745c8e4178588b@mail.gmail.com","subject":"Re: Git and git-svn question.","fromName":"Bob Cotton","fromEmail":"bob.cotton@rallydev.com","sentAt":"2008-03-28T14:38:25Z","receivedAt":"2008-03-28T14:38:25Z","isPatch":false,"sender":{"key":"bob.cotton@rallydev.com","avatar":null},"body":"\"Jean-Baptiste Quenot\" <jbq@caraldi.com> writes:\n\n> Hi Bosko,\n>\n> 2008/3/28, Bosko Ivanisevic <ivanisev@sezampro.com>:\n>> My company uses SVN and I have to work on the code from two offices.\n>>  Since SVN is far away from git in branching I've decided to set up git\n>>  repository as a mirror of company's SVN repo, which I would use as\n>>  intermediate repository for my code:\n>>\n>>  git svn clone -t tags -b branches -T trunk\n>>  svn+ssh://company_server/path_to_svn_repo --prefix=company/\n>\n> -t tags -b branches -T trunk == -s\n>\n>>  Since I just started to use git I wonder if anyone can give me any hint\n>>  what is the best way to accomplish following tasks with git:\n>>\n>>  - In office 1 and office 2 I clone git repository that is a mirror of SVN:\n>>    git clone ssh://company_server/path_to_git_repo\n>\n> You can't do that as SVN information is not cloned.  You have to call\n> git-svn clone on every working copy.\n\ngit-svn clone takes on the order of 6 hours for us. I've had some luck\nwith \"pre-clone/post-clone\" steps that:\n\npre-clone (which is run after 'git svn clone')\n\n1. create local branches for all 'remote' (svn) branches. This is so\n   'git clone' will create 'remote branches'. These are just\n   placeholders for the post-clone step:\n\n   git branch -r | grep -v tags | sed -rne 's, *([^@]+)$,\\1,p' | while read branch; do\n     echo \"git branch $branch $branch\"\n   done | sh\n\n2. create real git tags from all svn tags (we never branch from tags):\n\n  git branch -r | sed -rne 's, *tags/([^@]+)$,\\1,p' | while read tag; do\n    echo \"git tag $tag 'tags/${tag}^'; git branch -r -d tags/$tag\"\n  done | sh\n\n3. Now, with this repo, we create a \"read-only\" bare repo:\n\n   git clone --bare repo /somewhere/public/repo.git\n\n4. cleanup the heads created from #1\n\n   git show-ref --heads | cut -d' ' -f 2 | grep -v master | while read branch; do\n     echo \"git branch -D `basename $branch`\"; \n   done  | sh\n\n5. Now everyone git-clones from this repo, and runs 'post-clone' (below):\n\n   git clone git://somewhere/public/repo.git\n\nWe run 1-4 in a cron nightly.\n\nAfter step 5, we 'post-clone':\n\n1. put all 'origin/remote' branches (created in pre-clone #1) back to\n   refs/remote/<branch>\n\n   for i in `git-branch -r | egrep -v 'HEAD|master'`; do\n     echo \"git update-ref refs/remotes/`basename $i` $i\"\n     echo \"git branch -D -r $i\"\n   done | sh\n\n2. delete origin/HEAD and origin/master\n\n   git update-ref --no-deref refs/remotes/origin/HEAD origin/master\n   git branch -D -r origin/HEAD\n   git branch -D -r origin/master\n\n3. delete the origin repo from the config:\n\n   git config --remove-section remote.origin\n   git config --remove-section branch.master\n\n4. re-init git-svn\n\n    git svn init -s <your svn repo>\n\n5. rebase\n \n    git svn rebase\n\nNow everyone has is working from the same git repo, and they have all\nbeen reconfigured so that svn is the 'origin'.\n\n- Bob\n"}]}