{"thread":{"id":"24319","subject":"Handling tags/branches after git-svn fetch during SVN to Git conversion","startedAt":"2010-07-07T13:36:55Z","lastAt":"2010-07-09T03:34:10Z","messageCount":7,"participants":["Bradley Wagner","Jacob Helwig"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"145021","messageId":"AANLkTim56UOYQJfX3M5Jpt0vXD8iTnkLuG68IjQG39Xn@mail.gmail.com","threadId":"24319","inReplyTo":null,"subject":"Handling tags/branches after git-svn fetch during SVN to Git conversion","fromName":"Bradley Wagner","fromEmail":"bradley.wagner@hannonhill.com","sentAt":"2010-07-07T13:36:55Z","receivedAt":"2010-07-07T13:36:55Z","isPatch":false,"sender":{"key":"bradley.wagner@hannonhill.com","avatar":"https://gravatar.com/avatar/8304e5020b13d5f8102220fae2f5dd607a2e114dbe62bbd92c1ab38fe0b69fdb?d=mp&s=160"},"body":"I had a fairly complicated config for my SVN to Git migration with\nmultiple branch and tag locations. Therefore, I had to break up the\n\"git svn clone\" because I didn't know how to pass multiple branch\nlocations to \"git svn clone\":\n\n1. git svn init\n2. Update .git/config with branch/tag locations\n[svn-remote \"svn\"]\n        url = file:///Users/Developers/git_transition/svn_repo\n        fetch = project/trunk:refs/remotes/svn/trunk\n        branches =\nproject/branches/{feature1-branch,feature2-branch}:refs/remotes/svn/*\n        branches =\nproject/branches/{6.x,5.x,4.x,3.x,archive}/*:refs/remotes/svn/*\n        tags = project/tags/{3.7.x,4.x,5.x,6.x,old-releases}/*:refs/remotes/svn/tags/*\n3. git svn -A/path/to/mappings fetch\n\nDo I need to convert these remote tags/branches into local Git\ntags/branches before pushing them to my remote Git repo or is there a\nway to push remote branches directly to my remote Git repo?\n\nThe command that someone else told me was \"git checkout -b\n<local_branch_name> <remote_branch_name>\". Though, I've seen other\nplaces mention different strategies for converting the branches.\n\nThe script I devised to convert the tags does this for each tags\nfolder to maintain the original commit date, author, and commit\nmessage:\n\ngit for-each-ref --format=\"%(refname)\" refs/remotes/svn/tags/6.x |\ngrep -v @ | while read tag; do GIT_COMMITTER_DATE=\"$(git log -1\n--pretty=format:\"%ad\" \"$tag\")\" GIT_COMMITTER_EMAIL=\"$(git log -1\n--pretty=format:\"%ce\" \"$tag\")\" GIT_COMMITTER_NAME=\"$(git log -1\n--pretty=format:\"%cn\" \"$tag\")\" git tag -m \"$(git log -1\n--pretty=format:\"%s%n%b\" \"$tag\")\" ${tag#refs/remotes/svn/tags/6.x/}\n\"$tag\"; done\n\nPlease let me know if this is correct.\n\nThanks!\n"},{"id":"145180","messageId":"AANLkTinSdinuL_ZiDsQ9b3wBaJGXRGn5BveS7dRbLZfW@mail.gmail.com","threadId":"24319","inReplyTo":"AANLkTim56UOYQJfX3M5Jpt0vXD8iTnkLuG68IjQG39Xn@mail.gmail.com","subject":"Re: Handling tags/branches after git-svn fetch during SVN to Git conversion","fromName":"Bradley Wagner","fromEmail":"bradley.wagner@hannonhill.com","sentAt":"2010-07-09T02:33:40Z","receivedAt":"2010-07-09T02:33:40Z","isPatch":false,"sender":{"key":"bradley.wagner@hannonhill.com","avatar":"https://gravatar.com/avatar/8304e5020b13d5f8102220fae2f5dd607a2e114dbe62bbd92c1ab38fe0b69fdb?d=mp&s=160"},"body":"I posted this question to StackOverflow and got back that I should use\nthe svn2git tool. Surely there has to be a native way to convert these\nbranches into local branches using git-svn.\n\nhttp://stackoverflow.com/questions/3206383/what-is-the-correct-way-to-convert-svn-remote-branches-and-tags-into-local-git-br\n\nOn Wed, Jul 7, 2010 at 9:36 AM, Bradley Wagner\n<bradley.wagner@hannonhill.com> wrote:\n>\n> I had a fairly complicated config for my SVN to Git migration with\n> multiple branch and tag locations. Therefore, I had to break up the\n> \"git svn clone\" because I didn't know how to pass multiple branch\n> locations to \"git svn clone\":\n>\n> 1. git svn init\n> 2. Update .git/config with branch/tag locations\n> [svn-remote \"svn\"]\n>        url = file:///Users/Developers/git_transition/svn_repo\n>        fetch = project/trunk:refs/remotes/svn/trunk\n>        branches =\n> project/branches/{feature1-branch,feature2-branch}:refs/remotes/svn/*\n>        branches =\n> project/branches/{6.x,5.x,4.x,3.x,archive}/*:refs/remotes/svn/*\n>        tags = project/tags/{3.7.x,4.x,5.x,6.x,old-releases}/*:refs/remotes/svn/tags/*\n> 3. git svn -A/path/to/mappings fetch\n>\n> Do I need to convert these remote tags/branches into local Git\n> tags/branches before pushing them to my remote Git repo or is there a\n> way to push remote branches directly to my remote Git repo?\n>\n> The command that someone else told me was \"git checkout -b\n> <local_branch_name> <remote_branch_name>\". Though, I've seen other\n> places mention different strategies for converting the branches.\n>\n> The script I devised to convert the tags does this for each tags\n> folder to maintain the original commit date, author, and commit\n> message:\n>\n> git for-each-ref --format=\"%(refname)\" refs/remotes/svn/tags/6.x |\n> grep -v @ | while read tag; do GIT_COMMITTER_DATE=\"$(git log -1\n> --pretty=format:\"%ad\" \"$tag\")\" GIT_COMMITTER_EMAIL=\"$(git log -1\n> --pretty=format:\"%ce\" \"$tag\")\" GIT_COMMITTER_NAME=\"$(git log -1\n> --pretty=format:\"%cn\" \"$tag\")\" git tag -m \"$(git log -1\n> --pretty=format:\"%s%n%b\" \"$tag\")\" ${tag#refs/remotes/svn/tags/6.x/}\n> \"$tag\"; done\n>\n> Please let me know if this is correct.\n>\n> Thanks!\n\n\n\n--\nHannon Hill - Put Us to the Test\nbradley.wagner@hannonhill.com | http://www.hannonhill.com\n"},{"id":"145181","messageId":"AANLkTinAhxIKD6U3u4OpPnt5kDMPGTyhDhhCRaFtU-gA@mail.gmail.com","threadId":"24319","inReplyTo":"AANLkTim56UOYQJfX3M5Jpt0vXD8iTnkLuG68IjQG39Xn@mail.gmail.com","subject":"Re: Handling tags/branches after git-svn fetch during SVN to Git conversion","fromName":"Jacob Helwig","fromEmail":"jacob.helwig@gmail.com","sentAt":"2010-07-09T02:54:45Z","receivedAt":"2010-07-09T02:54:45Z","isPatch":false,"sender":{"key":"jacob.helwig@gmail.com","avatar":"https://avatars.githubusercontent.com/u/14557?v=4"},"body":"On Wed, Jul 7, 2010 at 06:36, Bradley Wagner\n<bradley.wagner@hannonhill.com> wrote:\n> Do I need to convert these remote tags/branches into local Git\n> tags/branches before pushing them to my remote Git repo or is there a\n> way to push remote branches directly to my remote Git repo?\n>\n\nYou don't need to \"convert\" the branches to local ones.  git-push will\naccept any ref your local repo knows about when you do a push.  For\nexample \"git push remote2 origin/branch-foo:refs/heads/branch-foo\"\nworks just fine, even if you don't have a \"local\" branch called\n\"branch-foo\", and it will push the branch-foo branch out to the\nremote2 remote repository.\n\nThe tags, you'll need to convert to _actual_ tags, instead of just\nbranches under a tags/ namespace.  Unless you're fine with them\nstaying as pseudo-tags, then you can just push them out as you would\nany other branch.\n\n-Jacob\n"},{"id":"145183","messageId":"AANLkTilnoIyrKg4PLSL71RDU-vyvIeNEtJ8STkOd9Lcq@mail.gmail.com","threadId":"24319","inReplyTo":"AANLkTinAhxIKD6U3u4OpPnt5kDMPGTyhDhhCRaFtU-gA@mail.gmail.com","subject":"Re: Handling tags/branches after git-svn fetch during SVN to Git conversion","fromName":"Bradley Wagner","fromEmail":"bradley.wagner@hannonhill.com","sentAt":"2010-07-09T03:01:18Z","receivedAt":"2010-07-09T03:01:18Z","isPatch":false,"sender":{"key":"bradley.wagner@hannonhill.com","avatar":"https://gravatar.com/avatar/8304e5020b13d5f8102220fae2f5dd607a2e114dbe62bbd92c1ab38fe0b69fdb?d=mp&s=160"},"body":"In your example, does \"remote2\" represent the name of my remote Git\nrepo? What is \"origin/branch-foo\" and does the path\n\"refs/heads/branch-foo\" need to actually exist in my .git directory?\n\nOn Thu, Jul 8, 2010 at 10:54 PM, Jacob Helwig <jacob.helwig@gmail.com> wrote:\n> On Wed, Jul 7, 2010 at 06:36, Bradley Wagner\n> <bradley.wagner@hannonhill.com> wrote:\n>> Do I need to convert these remote tags/branches into local Git\n>> tags/branches before pushing them to my remote Git repo or is there a\n>> way to push remote branches directly to my remote Git repo?\n>>\n>\n> You don't need to \"convert\" the branches to local ones.  git-push will\n> accept any ref your local repo knows about when you do a push.  For\n> example \"git push remote2 origin/branch-foo:refs/heads/branch-foo\"\n> works just fine, even if you don't have a \"local\" branch called\n> \"branch-foo\", and it will push the branch-foo branch out to the\n> remote2 remote repository.\n>\n> The tags, you'll need to convert to _actual_ tags, instead of just\n> branches under a tags/ namespace.  Unless you're fine with them\n> staying as pseudo-tags, then you can just push them out as you would\n> any other branch.\n>\n> -Jacob\n>\n\n\n\n-- \nHannon Hill - Put Us to the Test\nbradley.wagner@hannonhill.com | http://www.hannonhill.com\n"},{"id":"145185","messageId":"AANLkTilNLjTn1FyRqqz5xmOi4rOnSIwMUy6dOb0c0sRt@mail.gmail.com","threadId":"24319","inReplyTo":"AANLkTilnoIyrKg4PLSL71RDU-vyvIeNEtJ8STkOd9Lcq@mail.gmail.com","subject":"Re: Handling tags/branches after git-svn fetch during SVN to Git conversion","fromName":"Jacob Helwig","fromEmail":"jacob.helwig@gmail.com","sentAt":"2010-07-09T03:09:01Z","receivedAt":"2010-07-09T03:09:01Z","isPatch":false,"sender":{"key":"jacob.helwig@gmail.com","avatar":"https://avatars.githubusercontent.com/u/14557?v=4"},"body":"remote2 would be the name of your remote repo, yes.\n\norigin/branch-foo would be equivalent to svn/branch-foo in your local\nrepo, if you did \"git branch -a\".  It should be the name of one of the\ngit-svn created branches.\n\nrefs/heads/branch-foo is telling git where to store the reference for\nthe branch within remote2.  It does not need to exist already, and\nshould not in your case.\n\nThe git-push man page has more in-depth explanations, if you're interested.\n\nOn Thu, Jul 8, 2010 at 20:01, Bradley Wagner\n<bradley.wagner@hannonhill.com> wrote:\n> In your example, does \"remote2\" represent the name of my remote Git\n> repo? What is \"origin/branch-foo\" and does the path\n> \"refs/heads/branch-foo\" need to actually exist in my .git directory?\n>\n> On Thu, Jul 8, 2010 at 10:54 PM, Jacob Helwig <jacob.helwig@gmail.com> wrote:\n>> On Wed, Jul 7, 2010 at 06:36, Bradley Wagner\n>> <bradley.wagner@hannonhill.com> wrote:\n>>> Do I need to convert these remote tags/branches into local Git\n>>> tags/branches before pushing them to my remote Git repo or is there a\n>>> way to push remote branches directly to my remote Git repo?\n>>>\n>>\n>> You don't need to \"convert\" the branches to local ones.  git-push will\n>> accept any ref your local repo knows about when you do a push.  For\n>> example \"git push remote2 origin/branch-foo:refs/heads/branch-foo\"\n>> works just fine, even if you don't have a \"local\" branch called\n>> \"branch-foo\", and it will push the branch-foo branch out to the\n>> remote2 remote repository.\n>>\n>> The tags, you'll need to convert to _actual_ tags, instead of just\n>> branches under a tags/ namespace.  Unless you're fine with them\n>> staying as pseudo-tags, then you can just push them out as you would\n>> any other branch.\n>>\n>> -Jacob\n>>\n>\n>\n>\n> --\n> Hannon Hill - Put Us to the Test\n> bradley.wagner@hannonhill.com | http://www.hannonhill.com\n>\n"},{"id":"145187","messageId":"AANLkTilJ9tAO6Zf9whowApqhcpXU8Qvm31Z9RrQ3QaS6@mail.gmail.com","threadId":"24319","inReplyTo":"AANLkTilNLjTn1FyRqqz5xmOi4rOnSIwMUy6dOb0c0sRt@mail.gmail.com","subject":"Re: Handling tags/branches after git-svn fetch during SVN to Git conversion","fromName":"Bradley Wagner","fromEmail":"bradley.wagner@hannonhill.com","sentAt":"2010-07-09T03:18:02Z","receivedAt":"2010-07-09T03:18:02Z","isPatch":false,"sender":{"key":"bradley.wagner@hannonhill.com","avatar":"https://gravatar.com/avatar/8304e5020b13d5f8102220fae2f5dd607a2e114dbe62bbd92c1ab38fe0b69fdb?d=mp&s=160"},"body":"Thanks. Yea I was just looking at the man page trying to find the\nnotation with the colon separated ref names.\n\nIs \":refs/heads/branch-foo\" equivalent to just saying \":branch-foo\" in\nthe remote Git repo? Do I need the refs/heads piece?\n\nI'm trying to understand what a usual \"git push origin branch-foo\"\nequates to using your syntax.\n\nOn Thu, Jul 8, 2010 at 11:09 PM, Jacob Helwig <jacob.helwig@gmail.com> wrote:\n> remote2 would be the name of your remote repo, yes.\n>\n> origin/branch-foo would be equivalent to svn/branch-foo in your local\n> repo, if you did \"git branch -a\".  It should be the name of one of the\n> git-svn created branches.\n>\n> refs/heads/branch-foo is telling git where to store the reference for\n> the branch within remote2.  It does not need to exist already, and\n> should not in your case.\n>\n> The git-push man page has more in-depth explanations, if you're interested.\n>\n> On Thu, Jul 8, 2010 at 20:01, Bradley Wagner\n> <bradley.wagner@hannonhill.com> wrote:\n>> In your example, does \"remote2\" represent the name of my remote Git\n>> repo? What is \"origin/branch-foo\" and does the path\n>> \"refs/heads/branch-foo\" need to actually exist in my .git directory?\n>>\n>> On Thu, Jul 8, 2010 at 10:54 PM, Jacob Helwig <jacob.helwig@gmail.com> wrote:\n>>> On Wed, Jul 7, 2010 at 06:36, Bradley Wagner\n>>> <bradley.wagner@hannonhill.com> wrote:\n>>>> Do I need to convert these remote tags/branches into local Git\n>>>> tags/branches before pushing them to my remote Git repo or is there a\n>>>> way to push remote branches directly to my remote Git repo?\n>>>>\n>>>\n>>> You don't need to \"convert\" the branches to local ones.  git-push will\n>>> accept any ref your local repo knows about when you do a push.  For\n>>> example \"git push remote2 origin/branch-foo:refs/heads/branch-foo\"\n>>> works just fine, even if you don't have a \"local\" branch called\n>>> \"branch-foo\", and it will push the branch-foo branch out to the\n>>> remote2 remote repository.\n>>>\n>>> The tags, you'll need to convert to _actual_ tags, instead of just\n>>> branches under a tags/ namespace.  Unless you're fine with them\n>>> staying as pseudo-tags, then you can just push them out as you would\n>>> any other branch.\n>>>\n>>> -Jacob\n"},{"id":"145189","messageId":"AANLkTimDSO6CeClHlrLlFQbYbXOhSPJMUUn24nlmP1-8@mail.gmail.com","threadId":"24319","inReplyTo":"AANLkTilJ9tAO6Zf9whowApqhcpXU8Qvm31Z9RrQ3QaS6@mail.gmail.com","subject":"Re: Handling tags/branches after git-svn fetch during SVN to Git conversion","fromName":"Jacob Helwig","fromEmail":"jacob.helwig@gmail.com","sentAt":"2010-07-09T03:34:10Z","receivedAt":"2010-07-09T03:34:10Z","isPatch":false,"sender":{"key":"jacob.helwig@gmail.com","avatar":"https://avatars.githubusercontent.com/u/14557?v=4"},"body":"On Thu, Jul 8, 2010 at 20:18, Bradley Wagner\n<bradley.wagner@hannonhill.com> wrote:\n> Thanks. Yea I was just looking at the man page trying to find the\n> notation with the colon separated ref names.\n>\n> Is \":refs/heads/branch-foo\" equivalent to just saying \":branch-foo\" in\n> the remote Git repo? Do I need the refs/heads piece?\n>\n\nThat really depends on whether or not branch-foo already exists or\nnot.  From what I remember, if you use the <local>:<remote> syntax,\nthen you need the refs/heads bit if the branch doesn't already exist.\n\n> I'm trying to understand what a usual \"git push origin branch-foo\"\n> equates to using your syntax.\n>\n\nIt's equivalent to:\n  git push origin refs/heads/branch-foo:refs/heads/branch-foo\n  git push origin branch-foo:refs/heads/branch-foo\n  # If branch-foo already exists on the remote end, it's also the same as:\n  git push origin refs/heads/branch-foo:branch-foo\n  git push origin branch-foo:branch-foo\n\n> On Thu, Jul 8, 2010 at 11:09 PM, Jacob Helwig <jacob.helwig@gmail.com> wrote:\n>> remote2 would be the name of your remote repo, yes.\n>>\n>> origin/branch-foo would be equivalent to svn/branch-foo in your local\n>> repo, if you did \"git branch -a\".  It should be the name of one of the\n>> git-svn created branches.\n>>\n>> refs/heads/branch-foo is telling git where to store the reference for\n>> the branch within remote2.  It does not need to exist already, and\n>> should not in your case.\n>>\n>> The git-push man page has more in-depth explanations, if you're interested.\n>>\n>> On Thu, Jul 8, 2010 at 20:01, Bradley Wagner\n>> <bradley.wagner@hannonhill.com> wrote:\n>>> In your example, does \"remote2\" represent the name of my remote Git\n>>> repo? What is \"origin/branch-foo\" and does the path\n>>> \"refs/heads/branch-foo\" need to actually exist in my .git directory?\n>>>\n>>> On Thu, Jul 8, 2010 at 10:54 PM, Jacob Helwig <jacob.helwig@gmail.com> wrote:\n>>>> On Wed, Jul 7, 2010 at 06:36, Bradley Wagner\n>>>> <bradley.wagner@hannonhill.com> wrote:\n>>>>> Do I need to convert these remote tags/branches into local Git\n>>>>> tags/branches before pushing them to my remote Git repo or is there a\n>>>>> way to push remote branches directly to my remote Git repo?\n>>>>>\n>>>>\n>>>> You don't need to \"convert\" the branches to local ones.  git-push will\n>>>> accept any ref your local repo knows about when you do a push.  For\n>>>> example \"git push remote2 origin/branch-foo:refs/heads/branch-foo\"\n>>>> works just fine, even if you don't have a \"local\" branch called\n>>>> \"branch-foo\", and it will push the branch-foo branch out to the\n>>>> remote2 remote repository.\n>>>>\n>>>> The tags, you'll need to convert to _actual_ tags, instead of just\n>>>> branches under a tags/ namespace.  Unless you're fine with them\n>>>> staying as pseudo-tags, then you can just push them out as you would\n>>>> any other branch.\n>>>>\n>>>> -Jacob\n>\n"}]}