Import SVN folder as Git branch

Steps overview

  1. Import each SVN folder as individual temporary Git repos
  2. Create a new Git main repo
  3. In main Git repo, set up branches to track each master branches in temporary Git repos

Import each SVN folder as individual temporary Git repos

First, you may need to map SVN users into Git users.

$ cd ~/projects/
$ svn co svn://svnserver.com/projectX
$ cd projectX/
$ svn log -q | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u > ../projects/authors.txt

Then edit the file as you need, for example mine:
pellaeon = Pellaeon Lin <nfsmwlin@gmail.com>

Import your SVN folders

$ cd ~/projects/
$ git svn clone -A ~/projects/authors --no-metadata svn://svnserver.com/projectX/your/svn/folder1 temp1
$ git svn clone -A ~/projects/authors --no-metadata svn://svnserver.com/projectX/your/svn/folder2 temp2
(and so on)

Create a new Git main repo


$ mkdir -p ~/projects/mainrepo/
$ cd ~/projects/mainrepo/
$ git init .

In main Git repo, set up branches to track each master branches in temporary Git repos

Pull in master

$ git remote add temp1 ~/projects/temp1
$ git pull temp1 master

For each branches, pull in from corresponding temp repos

$ git checkout -b temp2
$ git remote add temp2 ~/projects/temp2
$ git pull temp2 master

Now you have the main repo you wanted, you can delete the temp repo.

References

Cannot create cross device working copy in Subversion 1.7

I’m no expert on this, my friend said that this is due to there is no guarantee that apr_file_rename() will success on different devices.

Based on the discussion here I was able to create a patch.

If you use FreeBSD ports, simply put the patch in /usr/ports/devel/subversion/files/, The port system will automatically apply this patch before build.

I have only tested this patch on Subversion 1.7.5 !