How to integrate svn branches into git branches with git-svn?

184 views Asked by At

i have not much svn experience but i am used to work with git.

I have the following svn repository structure and revisions.

https://server/svn/solution/trunk/solution.sln @r100
https://server/svn/solution/trunk/project1/project1.csproj @r150
https://server/svn/solution/trunk/project2/project2.csproj @ r160

https://server/svn/solution/branches/solution.sln @r100
https://server/svn/solution/branches/project1/project1.csproj @r200
https://server/svn/solution/branches/project2/project2.csproj @ r350

When i clone the repository

git svn clone https://server/svn/solution --stdlayout

I get everything

(master)$ git branch -a  
* master  
  remotes/project1  
  remotes/project2  
  remotes/trunk  

When i want to create a local branch for a remote one

(master)$ git checkout -b local-project1 project1

all i get when i checkout the branch is project1. The branch does not contain anything from

https://server/svn/solution/branches/solution.sln @r100

To solve the problem i tried the following:

(local-project1)$ git checkout master
Switched to branch 'master'.
(master)$ git branch local-project1 -D
Deleted branch local-project1 (was 1111a11).
(master)$ git checkout -b local-project1
Switched to new branch 'local-project1'.
(local-project1)$ pwd
/c/workingcopies/solution
(local-project1)$ cd project1
(local-project1)$ pwd
/c/workingcopies/solution/project1
(local-project1)$ git branch --set-upstream local-project1 remotes/project1
Branch local-project1 set up to track local ref refs/remotes/project1.
(local-project1)$ git svn fetch
(local-project1)$ git reset --hard ae8e9b1a ;# go to last commit of the remote branch

The fetch gets the last revision from the branch in the repository and the HEAD is set to the last commit but i still only get project1 in the branch, not the solution. Any advice and help is appreciated.

1

There are 1 answers

3
AFoglia On BEST ANSWER

The problem is that you do not have a standard svn layout. A standard layout would have directories under branches for each branch, like so.

repo/
  +-- trunk
  |     +-- solution.sin
  |     +-- project1/project1.csproj
  |     +-- project2/project2.csproj
  +-- branches/
        +-- branch01/
              +-- solution.sin
              +-- project1/project1.csproj
              +-- project2/project2.csproj

You instead have a trunk and a branch called "branches" located in the same directory as trunk.

I'm not sure if git can be told to handle this properly. I have some ideas: You could edit .git/config to make git look for a branch in the topmost directory, but then it might be confused when it tries to make a branch called trunk while it already has a trunk.