2

We currently use subversion as our version control system, we have decided that we are moving to git. I have been having a hard time moving my subversion system with a standard layout into git. I have used git svn as much as I can.

What i need to accomplish is convert our subversion system to git with all commit history and as well as tags and branches. Then to be able to separate each of the projects into separate git repositories with their individual history, then combine each of these individual repositories into submodules.

I would appreciate any ideas on how to most easily accomplish this.

svnroot/
|-- branches
|-- tags
|-- trunk
    |-- project A
    |-- project B
    `-- project C

Please and thank you

1

1 Answer 1

2

If your svn repository layout is:

svnroot/
|-- projectA
|   |-- branches
|   |-- tags
|   `-- trunk
|-- projectB
|   |-- branches
|   |-- tags
|   `-- trunk
`-- projectC
    |-- branches
    |-- tags
    `-- trunk

Then you could create separate git repositories for each project e.g., projectA:

$ git svn clone --stdlayout https://svn.example.net/svnroot/projectA

After that you could create the main git repo (git init) and add the created git repos for project{A,B,C} as submodules to it (git submodule).

But it is probably not what you want; from the git submodule manual:

Submodules allow foreign repositories to be embedded within a dedicated subdirectory of the source tree, always pointed at a particular commit.

They are not to be confused with remotes, which are meant mainly for branches of the same project; submodules are meant for different projects you would like to make part of your source tree, while the history of the two projects still stays completely independent and you cannot modify the contents of the submodule from within the main project.

If you'd like to modify project{A,B,C} from within the main project and keep the unite history of the projects then the submodules are not appropriate for the task.


For the provided svn repo layout:

svnroot/
|-- branches
|-- tags
|-- trunk
    |-- projectA
    |-- projectB
    `-- projectC

try to create the git repositories using --trunk, --branches, --tags arguments e.g.:

$ git svn clone                       \
>    --trunk trunk/projectA           \
>    --branches branches              \
>    --tags  tags                     \
>    https://svn.example.net/svnroot  \
>    projectA

On completion the .git/config file should contain something like:

[svn-remote "svn"]
        url = https://svn.example.net/svnroot
        fetch = projectA/trunk:refs/remotes/trunk
        branches = branches/*:refs/remotes/*
        tags = tags/*:refs/remotes/tags/*

You could use --ignore-paths=<regex> to skip matching paths from the project.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.