1

We are using a non standard layout for our projects in SVN.

http://svn_root/Path/ABC/development contains multiple folders. The folders are either an application folder or a library folder. SVN repo contains multiple actual projects as subdirectories

Im trying to clone a single folder under development folder to a dedicated repo in GIT.

SVN folder structure is

SVN_ROOT/
    ABC/
       development/
             Project1/
                     files
             Library1/
                     files
             Project2/
                     files

So when i run the git svn clone im trying to achieve this folder structure

GIT_Repo/
        .git
        Project1/
              files

It is important that the files remain in the Project1 folder

I tried the following commands and several such variants

git svn clone http://SVN_ROOT/ABC/development/Project1 GitRepo
git svn clone --trunk=/ABC/development/Project1 http://SVN_ROOT/ GITRepo

All the commands end up with the same folder structure

GITRepo/
     files

The command is unable to retain the project folder and placing the project files directly in the GIT Repo.

2 Answers 2

3

You can use below command to clone, and it will make the git repo structure as root/Project1/files:

git svn clone http://SVN_ROOT/ABC/development --include-paths Project1

If you want to remove the unnecessary commits (for the changes out of Project1 folder), you can clone the url for http://SVN_ROOT/ABC/development/Project1, and then create Project1 folder and move files into it:

git svn clone http://SVN_ROOT/ABC/development/Project1 Gitrepo
cd Gitrepo
mkdir Project1
mv * Project1
git add .
git commit -m 'move files into Project1/files'
Sign up to request clarification or add additional context in comments.

3 Comments

this trick works but this is creating a ton of unnecessary commits before the first actual commit for Project1 shows up in the log history. Anyway to avoid it??
The command will truly migrate the commits out of Project1. If you want to skip unnecessary commits, you can refer the alternative way which I added in the end of my answer, you can have a try.
But what if I need to clone Project1 and Project2 into Gitrepo and want to remove unnecessary commits? git svn clone http://SVN_ROOT/ABC/development --include-paths 'Project1|Project2' will produce unnecessary commits.
0

Make a folder called GITRepo. Inside that folder run

git svn clone http://SVN_ROOT/ABC/development/Project1

If you wanted all of the projects and libraries,

git svn clone http://SVN_ROOT/ABC/development GitRepo

When you run git svn clone http://SVN_ROOT/ABC/development/Project1 GitRepo, you will get a folder called GitRepo with all of the files/folders starting in Project1.

Edit:

Create the folder GIT_Repo Inside that folder run

git svn init http://SVN_ROOT/ABC/development

Open .git/config. It should be something like

[svn-remote "svn"]
    url = http://SVN_ROOT/ABC
    fetch = development/Project1:refs/remotes

Then run git svn fetch

1 Comment

Hi Ben, I do not want all my projects in a single repo. Since every folder under the development folder is either an application or a library, I have to create a git repo for every folder.

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.