There’s a really helpful guide published by Atlasssian: Migrate to Git from SVN which lists five steps:
- Prepare your environment for the migration.
- Convert the SVN repository to a local Git repository.
- Synchronize the local Git repository when the SVN repository changes.
- Share the Git repository with your developers via Bitbucket Github.
- Migrate your development efforts from SVN to Git.
Starting the steps:
$ cp ~/Downloads/svn-migration-scripts.jar ~/ $ cd $ java -jar ~/svn-migration-scripts.jar verify $ java -jar ~/svn-migration-scripts.jar create-disk-image 5 GitMigration $ cd GitMigration $ java -jar ~/svn-migration-scripts.jar authors "svn://path-to-SVN-respository" > authors.txt # the above command generates authors.txt, which then needs editing.
Then I hit problems following the Atlasssian: Migrate to Git from SVN. The hint of the solution was found here. I ended-up splitting the
git svn clone into
git svn init followed be editing the
.git/config file then followed by
git svn fetch.
For example to import history from SVN I ran:
$ cd GitMigration $ git svn init --trunk="/folder/within/repository" "svn://path-to-SVN-respository" GitRepositoryName
GitRepositoryName/.git/config to read:
[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true precomposeunicode = true [svn-remote "svn"] url = svn://path-to-SVN-respository fetch = folder/within/repository:refs/remotes/origin/trunk branches = "" tags = "" [svn] authorsfile = /Users/nickager/GitMigration/authors.txt
The main additions to the auto generated
config are the lines:
branches = "" tags = "" [svn] authorsfile = /Users/nickager/GitMigration/authors.txt
… as various trials failed to import SVN branches successfully.
then import the SVN history into Git with
git svn fetch:
$ cd GitRepositoryName $ git svn fetch
then add a remote and push to the git repository (the repository has to have been created on GitHub before taking this step):
$ git remote add origin https://github.com/gituser/gitrespository.git $ git push origin master
Finally before the big switch to Git, while people are still checking into SVN, keep the Git repository in sync with changes in SVN with a bash script to update Github from SVN every 20minutes:
#!/bin/bash while true; do echo "*** updating iOS" cd /Volumes/GitMigration/GitRepositoryName git svn fetch git svn rebase git push origin master echo "*** sleeping for 20minutes" sleep 1200 done