I migrated a work repository from Subversion to Git last week. It went surprisingly smoothly. There were a more steps than I expected after reading various, selected, sources.
My repository was in "standard layout" containing only a single tree/project. I was sent a dump of the repository created with svndump. If you have direct access to your svn repository, skip step one. Similarly you can skip the github steps or replace them with your own "primary git server."
Note, if you don't want to maintain the svn tags and branches, then there is a simple single step solution using git-svn. This works if you don't have tags and branches to keep, or you just want a personal git checkout of a remote svn repository.
git svn clone --no-metadata --stdlayout
--A users.txt http://svn/repo/here/ new_checkout_name/
Overview:
- import svn dump into svn repository
- create mapping file of svn committer to email address
- create empty git repository
- cd to git repository
- import from svn repo to git repo
- pull branch and tag information from svn to git
- create github repository
- add remote repository
- push all tags and branches to github repository.
- import svn dump into svn repository from dump file svn_repo.dump
% svnadmin create svnrepo % svnadmin load svnrepo < svn_repo.dump
- create mapping file of svn committer to email address
Create a file called authors.txt and fill it with line separated “svn-name = git-name” pairs. #example: % cat authors.txt user_a = Alpha <alpha@example.com%gt; user_b = B Dawg <bdawg@github.example.com%gt;
- create empty git repository
% mkdir gitrepo % git init gitrepo
- import from svn repo to git repo
svn repo path must be an absolute path when using file://# git svn clone file:///pathto/svnrepo /pathto/gitrepo –no-metadata -A authors.txt --stdlayout
% git svn clone file://$(pwd)/svnrepo gitrepo/ --no-metadata -A authors.txt --stdlayout
- cd to the git repository
% cd gitrepo
- pull branch and tag information from svn to git
tags and branches are both viewed as remote branches, tags are prefixed with "tag/".
For each branch you want to migrate, make a local branch.
For each tag, make a local tag.% git svn fetch # fetch remote branches and tags from svn % git branch -r # view remote branches % git branch local_branch remote_branch # for each branch to migrate % git tag local_tag tags/remote_tag # for each tag to migrate % git branch # check work by viewing local branches and ... % git tag -l # ... local tags
- create github repository
( github repo ui, create yourrepo )- add remote repository
% git remote add origin git@github.com:yourname/yourrepo
- push all tags and branches to github repository.
% git push origin --tags # push all tags % git push origin --all # push all branches
- create empty git repository