Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import local git repository into svn?

Tags:

git-svn

I am working on local git repository and I need to push my local git into existing svn repository. My git repository is pure local git repository, it was not init using git svn clone.

How can I import this local git repo into svn?

Preferably I'ld like to keep the git history being imported into SVN.

Currently the SVN repository is structure as:

https://svnrepohost
           /branches
           /tags
           /trunk
                  /projectA
                  /projectB
                  /newProject

What I need it is to import my git repository into the https://svnrepohost/trunk/newProject above, assuming the newProject folder is empty.

like image 448
DJ. Avatar asked Jun 22 '12 00:06

DJ.


People also ask

How do I clone a local repository in SVN?

# Clone a repo with standard SVN directory layout (like git clone): git svn clone http://svn.example.com/project --stdlayout --prefix svn/ # Or, if the repo uses a non-standard directory layout: git svn clone http://svn.example.com/project -T tr -b branch -t tag --prefix svn/ # View all branches and tags you have ...


1 Answers

I have finally solved this problem by the following steps:

  1. Setup appropriate project folder in svn to be imported to, for example http://svnrepo/svn/trunk/newProject

  2. Create a new git-svn repository

    git svn clone http://svnrepo/svn/trunk/newProject

  3. Add the git repo that we want to import as remote to the new git-svn repo

    git remote add origin ../original-git-repo

  4. Pull all the data from original-git-repo

    git pull origin master --allow-unrelated-histories

  5. Rebase local repository against svn

    git svn rebase

  6. Commit the changes into svn

    git svn dcommit

  7. Clean up the remote

    git remote delete origin

like image 109
DJ. Avatar answered Oct 03 '22 19:10

DJ.