2

I am using "git svn" to interact with a large SVN repo with non-standard branching convention. I see that there are multiple ways to clone the svn repo / branches as pointed out here

I am seeing really different behaviors:

Say the SVN repo is as follows:

http://svn.mycom.com/svn/Project
-->trunk
-->defects
-->uat

Production is in "trunk", branches are in "defects", current development is in "uat".

So that being said I could do the following

1. clone direct uat..

$ git svn clone http://svn.mycom.com/svn/Project/uat

when I do this my .git/config file looks like:

[svn-remote "svn"]
    url = http://svn.mycom.com/svn/Project/uat
    fetch = :refs/remotes/trunk

I then added branches as described here My .git/config looks similar to:

[svn-remote "svn"]
    url = http://svn.mycom.com/svn/Project/uat
    fetch = :refs/remotes/trunk
[svn-remote "task1"]
    url = http://svn.mycom.com/svn/Project/defects/task1
    fetch = :refs/remotes/task1

Now when I run

 $git log --decorate --all --graph

I see that my new branch has only 1 commit, ie. branch creation it does not relate to the actual history to master. it shows its own history line without any connection to prior commits.

2. Clone with -T then adding branches Alternative solution I found was:

$git svn clone http://svn.mycom.com/svn/Project/ -T uat Project --no-minimize-url
   Since the "Defects" has lot many branches, and it would take hours, i then did:

[svn-remote "svn"]
    url = http://svn.mycom.com/svn/Project
    fetch = uat:refs/remotes/trunk
    branches = defects/{task1}:refs/branches/*

This seems to work nice and I do get the history. I am wondering what is the better way of the two, if there is anything I need to think about going from one vs the other option. In this option though, if I have to add another branch, I cannot simply edit the branches section and new branch name in the comma separated list like branches = defects/{task1,task2}. This does not work feels like a GIT defect. I then just add another fetch line below the branches

[svn-remote "svn"]
    url = http://svn.mycom.com/svn/Project
    fetch = uat:refs/remotes/trunk
    branches = defects/{task1}:refs/branches/*
    fetch = defects/task2:refs/branches/task2

This works fine, i get the branch history and able to switch w/o issues. but just feels like a hack. I wish there was a way to just append it to branches list which would look clean.

Community
  • 1
  • 1
bond
  • 11,236
  • 7
  • 48
  • 62

2 Answers2

1

I use and prefer the second way, which IMO is right way to do it. In the 2nd way you will have all the history of the repository and you can easly switch between the branches you need. Also I think that the 1st way will give you some problems if you're gonna create a new branch locally and then commit it to the SVN.

Atropo
  • 12,231
  • 6
  • 49
  • 62
  • Thanks Atropo, I agree, btw, how do you add new branches later on? I cannot simply add new branch name in the comma separated list :( – bond Apr 08 '13 at 16:39
0

After using it for few days, the best option that worked is Option #2.

Note: instead of adding "fetch" line for new branches that got created later on. I found that adding new branch name as the first thing on the list, did the trick. New branch info was pulled.

[svn-remote "svn"]
 url = http://svn.mycom.com/svn/Project
 fetch = uat:refs/remotes/trunk
 branches = defects/{task2,task1}:refs/branches/*

If by doing this didn't pull the branch, simply delete ".git/svn/.metadata" folder and run

git svn fetch

It will basically fetch the info all over again, but at least looks clean. Adding fetch line is fine as well. Personally I dont care either way. If you are meticulous, you can add in branches as mentioned above.

bond
  • 11,236
  • 7
  • 48
  • 62