Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Migrates multiple SVN repos to GitHub, without anything fancy (no Ruby, no dependencies, no issues with Cygwin paths).
Migrates multiple SVN repos to GitHub, without anything fancy (no Ruby, no dependencies, no issues with Cygwin paths). SVN tags are created as Git tags and properly pushed to GitHub. To run:
1) Edit run-authors.sh to have your SVN repos. Run it to get an authors.txt file.
2) Edit the authors.txt to have GitHub names and emails if you like. You must use GitHub user email addresses if you want contributions to be associated with GitHub accounts.
3) Create the GitHub projects, without populating it with a readme or license.
4) Edit run-convert.sh to have your SVN repos, GitHub user URL, and GitHub project name. Run it.
5) Done!
cp authors.txt authors.temp
svn log -q $1 | awk -F '|' '/^r/ {sub("^ ", "", $2); sub(" $", "", $2); print $2" = "$2" <"$2">"}' | sort -u >> authors.temp
cat authors.temp | sort -u > authors.txt
rm authors.temp
svn_url=$1;
github_url=$2;
name=$3;
echo "Cloning SVN repository to $name.svn... $svn_url"
rm -rf $name.svn
git svn clone $svn_url --no-metadata -A authors.txt --stdlayout $name.svn
cd $name.svn
echo "Creating .gitignore file..."
git svn show-ignore > .gitignore
git add .gitignore
git commit -m 'Convert svn:ignore properties to .gitignore.'
echo "Initializing git repository... $name.git"
cd ..
rm -rf $name.git
git init --bare $name.git
cd $name.git
git symbolic-ref HEAD refs/heads/trunk
echo "Pushing to git repository... $name.git"
cd ../$name.svn
git remote add bare ../$name.git
git config remote.bare.push 'refs/remotes/*:refs/heads/*'
git push bare
echo "Renaming trunk to master..."
cd ../$name.git
git branch -m trunk master
echo "Converting SVN tag branches to git tags..."
git for-each-ref --format='%(refname)' refs/heads/tags | cut -d / -f 4 |
while read ref
do
git tag -a "$ref" -m "Tag: $ref" "refs/heads/tags/$ref";
git branch -D "tags/$ref";
done
echo "Pushing to github... $github_url$name"
git push --mirror --follow-tags $github_url$name
echo "Done!"
rm authors.txt
sh authors.sh http://kryo.googlecode.com/svn
sh authors.sh http://kryonet.googlecode.com/svn
sh authors.sh http://minlog.googlecode.com/svn
sh authors.sh http://reflectasm.googlecode.com/svn
sh authors.sh http://jsonbeans.googlecode.com/svn
sh authors.sh http://yamlbeans.googlecode.com/svn
sh authors.sh http://tablelayout.googlecode.com/svn
sh authors.sh http://reflectasm.googlecode.com/svn
sh authors.sh http://wildcard.googlecode.com/svn
sh authors.sh http://scar.googlecode.com/svn
sh convert.sh http://reflectasm.googlecode.com/svn https://github.com/EsotericSoftware/ reflectasm
sh convert.sh http://kryo.googlecode.com/svn https://github.com/EsotericSoftware/ kryo
sh convert.sh http://minlog.googlecode.com/svn https://github.com/EsotericSoftware/ minlog
sh convert.sh http://kryonet.googlecode.com/svn https://github.com/EsotericSoftware/ kryonet
sh convert.sh http://reflectasm.googlecode.com/svn https://github.com/EsotericSoftware/ reflectasm
sh convert.sh http://jsonbeans.googlecode.com/svn https://github.com/EsotericSoftware/ jsonbeans
sh convert.sh http://yamlbeans.googlecode.com/svn https://github.com/EsotericSoftware/ yamlbeans
sh convert.sh http://table-layout.googlecode.com/svn https://github.com/EsotericSoftware/ tablelayout
sh convert.sh http://wildcard.googlecode.com/svn https://github.com/EsotericSoftware/ wildcard
sh convert.sh http://scar.googlecode.com/svn https://github.com/EsotericSoftware/ scar
@C-Duv

Thanks, your scripts were very handy.
Had some issue with git svn show-ignore that failed: fixed it by using --id trunk argument.

Also had special needs (no GitHub, preserve empty directories, add a develop branch) so I've improved them.
If that's of any help to anyone, here they are: https://github.com/C-Duv/sysadmin-scripts/tree/master/gitlab/svn2gitlab

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.