



I spent a lot of today trying to move my Unlogo repository from Google Code to Github. Kind of a waste, but maybe it will help someone else.
When you make a Github repository, one of the first things it asks you is if you would like to import a subversion repository. But for some reason this wasn’t working with the Unlogo Google Code repository. It would just hang while trying to get the authors or something…
There is also an entire help page about moving from Subversion to Github which recommends svn2git or git-svn. Neither of these worked for me either. They would just kind of fail silently and nothing would happen. So, being the masochist that I am, I decided to just write a little bash script that loops through each subversion revision and commits it to Github.
I’m sure this script is missing a lot of things — I am by no means a SVN, GIT, or bash master. It doesn’t deal with deleted files at all — I couldn’t figure out how to do that, so I am going to just remove all orphaned files at the end manually. But the nice thing is that is is simple and you can customize/improve it how you wish.
Suggestions are very welcome.
script is after the jump.
#!/bin/bash # First make the git directory # Of course, you will want to change this to your repository echo "Making the local Github repository" mkdir Unlogo cd Unlogo git init git remote add origin git@github.com:jefftimesten/Unlogo.git #Make a .gitignore file that will ignore the .svn metafiles echo ".svn" >> .gitignore #Check out revision 1 of your SVN repository into the current directory #Similarly, you will want to change this to your subversion repository echo "Checking out the subversion repository into the same directory" svn co -r 1 http://unlogo.googlecode.com/svn/trunk/ . #Get the total number of revisions in your repository REVISIONS=`svn info --revision HEAD | perl -ne 'if(m/(Revision:) ([0-9]+)/i){print $2;}'` echo "$REVISIONS total revisions. Starting..." for ((i=1; iI just committed 129 revisions of my SVN repository to Github. Nice, eh?