Converting part of a svn repository to git

In moving my projects over to git, I stumbled across a troublesome issue. In one of my projects existed a folder along side trunk, tags and branches that had stuff I needed to be converted. However I wanted to convert these as individual git repositories.

So, after reading “git –help svn clone” and finding nothing to help me with this issue, I headed to the search engines. It took some time between search engines and asking some friends. As a note, Git 1.7 has sparse abilities, however I never got that far to try it out. I found out that git 1.6.4 included a new parameter which does the job just nicely.

I stumbled across this on the Tech Debug blog.

So in the end the following command is an example of what I did, with real data omitted.

$ git svn clone http://example.com/svn/project/folder --no-minimize-url --no-metadata -A authors-transform.txt folder

This did the job exactly as I needed it to. It converted just the folder in the repository without so much of a complaint. Now that I review the git man page for svn, I do see I missed it.

When tracking multiple directories (using –stdlayout, –branches, or –tags options), git svn will attempt to connect to the
root (or highest allowed level) of the Subversion repository. This default allows better tracking of history if entire projects
are moved within a repository, but may cause issues on repositories where read access restrictions are in place. Passing
–no-minimize-url will allow git svn to accept URLs as-is without attempting to connect to a higher level directory. This option
is off by default when only one URL/branch is tracked (it would do little good).

2 Comments

  1. In moinvg from self-hosted SVN to github-hosted Git did you have any concerns about putting your code in the hands of a third-party(albeit competent) provider?I have horrible visions of my repo accidentally being set to “public” and someone cloning my entire startup’s codebase – to be forever hosted on the interwebs somewhere.Did you look at self-hosted Git?

  2. I have no need for private repositories. So no I didn’t bother using my site to host my git repositories.

    Well you have that concern with any repository you use. Git just makes this easier as its a DCVS, which means there is no central repository really. Your solution would be for anyone with access to your private repo to sign a NDA among other things to give you legal backing to take action against them.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.