![]()
minht
Posted 1 year ago
by minht
Migrating an SVN repo to git on OSX using MacPorts
Previously I posted how to migrate a snapshot of SVN to git, but if you’re interested in keeping the revisions here is a how-to based on these helpful pages (1|2|3):
Update MacPorts (installing Xcode 4.3 may have broken MacPorts because it can’t find a C compiler or similar: installing Apple’s Developer Command Line Tools fixed this for me):
sudo port selfupdate
Install git using MacPorts with appropriate svn hooks:
sudo port install git-core +svn
Specify git author names and emails associated with each SVN author username in a file (authors.txt) which looks like:
svn_username = Firstname Lastname <blah@email.something>
minh = Minh Tran <minh@hungrysky.com>
Clone your svn repo to a temporary git repo (~/temp). We had a standard SVN repo layouts e.g. trunk, tags, branches at the root but if yours is named or located differently, you can specify each of these using -T, -t and -b respectively and perhaps drop —stdlayout (I haven’t tried this though). If you don’t have a login to your SVN repo you can omit —username part.
git svn clone http(s)://url.to.your.svn.repo —no-metadata -A ~/location/of/authors.txt —stdlayout ~/temp —username svn_username
Drop the SVN links to your git repo by cloning it:
git clone ~/temp newrepo
Our git repo is hosted on bitbucket, so create a new repo (unfortunately, import repository didn’t work hence this post). If your git repo is hosted on a remote server you can set this by (make sure you are in the directory of your newrepo):
git remote set-url origin git@url.of.git.repo/reponame.git
Finally:
git push -u origin master
