Import Git repo with history log into Subversion repo

Many thanks to http://eikke.com/importing-a-git-tree-into-a-subversion-repository/

When typing git svn init exclude /trunk at the end (I failed with this), because .git/config in the svn section defines the fetch path and appends the /trunk

[svn-remote "svn"]
        url = https://EXAMPLE.COM:PORT/svn/repo
        fetch = trunk:refs/remotes/origin/trunk
        branches = branches/*:refs/remotes/origin/*
        tags = tags/*:refs/remotes/origin/tags/*

So in my case this worked:

$ git svn init -s https://EXAMPLE.COM:PORT/svn/repo
$ git svn fetch
$ git log --pretty=oneline master | tail -n1
88464cfdf549a82b30ee7c52e53e2b310f0d9ec4 Initial commit

$ git show-ref trunk
741ab63aea786882eafd38dc74369e651f554c9c refs/remotes/trunk

$ echo "88464cfdf549a82b30ee7c52e53e2b310f0d9ec4 741ab63aea786882eafd38dc74369e651f554c9c" >> .git/info/grafts

Now if you check git log and scroll to the bottom you will see another entry under your ‘Initial commit’ (first commit), that’s from where SVN commit will merge it’s content from Git.

commit 29df3f4db3bcd7f590db2426a69760b0c971432a
Author: Michal Zuber 
Date:   Mon Jun 23 08:41:15 2014 +0200

    Initial commit

commit d3b17c72d666c463e1d4fb1e363319d20024106e
Author: VisualSVN Server 
Date:   Thu Feb 26 08:34:40 2015 +0000

    Initial structure.
    
    git-svn-id: https://EXAMPLE.com:PORT/svn/repo/trunk@1 8ce696b1-2aa8-b049-9446-9fee1243c08b

Finally firing git svn dcommit

$ git svn dcommit
Committing to ...

Will push the Git stuff into Subversion repo.

To start fresh remove rm -rf .git/svn/ and [svn] section from .git/config which was added by git svn init

Advertisements

About Michal Zuber

Full stack developer, biker and rollerblader. Owner and developer at https://nevilleweb.sk/ Co-founded http://neville.sk/ Blog at https://michalzuber.wordpress.com/
This entry was posted in cli, git, linux, svn and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s