Catch up on stories from the past week (and beyond) at the Slashdot story archive

 



Forgot your password?
typodupeerror
×
Debian

Journal marcello_dl's Journal: Quick and dirty subversion to git repository migration

while git-svnimport can be used for proper subversion repositories, I had issues with it and a personal svn repository which didn't follow the traditional svn layout with trunk branches tags (shame on me). Well why not simply iterate over the revisions and importing them? Seems to work. Here's how I did it:

first run
svn info [URL of the svn repository you want to migrate]
to discover how many revisions it has till now.

then let's get the commit messages so we can recycle them:

for i in `seq 1 [number of revisions]`; do svn log -r $i [URL of svn repository] > /tmp/svnlog$i.txt; done

then:
svn co --revision 1 [path to the svn repository you want to migrate]
so that a dir with a working copy is created, we'll call it [target git repository]. Now let's migrate all changes:


cd [target git repository]/
git-init
echo *.svn >> .git/info/exclude
for i in `seq 1 [number of revisions]`; do cd .. ; svn co --revision=$i [URL of source svn repository] ; cd $OLDPWD ; git add . ; git-commit -a -F /tmp/svnlog$i.txt; done

That should do it. Better do a
git-gc --prune --aggressive
(Do it when nobody else is accessing the new git repository!!!) so that you save space on disk, and a
git clean -d
to get rid of now useless .svn dirs.

Software production is assumed to be a line function, but it is run like a staff function. -- Paul Licker

Working...