Final goodbye to Subversion

When it comes to version control the world has pretty much moved on from Subversion and adopted distributed version control systems like Git and Mercurial. There has been one area though where Subversion has resisted my efforts to move on and that is with Xcode. The Xcode Source Management system only integrates with CVS, Subversion or Perforce. There is no support for “modern” solutions such as Git or Mercurial.

The Subversion integration with Xcode is not bad in that is provides a graphical overview of what is changing in your project which reminds me of using the TortoiseSVN Windows Explorer shell extension. So you get “M” or “?” symbols next to source files when you change or add a file to the project. You can also easily right-click on a file to add it to a repository and view the change log, etc.

The reality is that this integration is fairly cosmetic and I still perform my basic version control operations from the command-line. Of course, it would be great if Apple added some direct support for Git but it is not something that has too much value in the end.

So I decided I would finally abandon my last Subversion based projects and move everything to Git. This has the additional benefit of making it easy to host everything on github. Of course, Git makes it real easy to migrate an existing repository whilst maintaining the full history of the project:

Create a clean copy of the Subversion repository

The first step is create a clean copy of the Subversion repository without all of the Subversion metadata (.svn directories):

$ mkdir myproject-tmp
$ cd myproject-tmp
$ git svn init http://path-to-repository/svn/myproject/trunk --no-metadata
  Initialized empty Git repository in ./myproject-tmp/.git/

Translate Subversion authors

Create an authors file to map Subversion authors to git users. In my case I needed an entry for commits performed without an author. The format is as follows:

(no author) = Real Name <email>

This then needs to be added to the project configuration:

$ git config svn.authorsfile ../user.txt

Import the repository

With everything prepared the import can begin. This can take a while for a large project and watching the output is like taking a trip down memory lane for your project:

$ git svn fetch

Clean up

Once the import is done you can clean up the temporary directory

$ git clone myproject-tmp myprojectrm -rf myproject-tmp

If you have not already done so you may also want to add some files to your global .gitignore file. I have the following X-code and OSX related entries:

# Ignore X-code files
build/
*~.nib
*.so
*.pbxuser
*.mode*
*.perspective*
# OSX Specific files
.DS_Store

Remote push

If you are storing a copy of the repository on a remote site now is a good time to push it:

$ git remote rm origin
$ git remote add origin git@github.com:/myproject.git
$ git push origin master

Never miss a post!

iOS Size Classes Cheat Sheet

Subscribe and get my free iOS Size Classes Cheat Sheet

Success! Now check your email to confirm your subscription and download your free guide to iOS Size Classes.

There was an error submitting your subscription. Please try again.

Unsubscribe at any time.
No time to watch WWDC videos?

Sign up to get my iOS posts direct to your inbox and I will send you a free PDF of my iOS Size Classes Cheat Sheet.

OK! Check your inbox (or spam folder) for an email to confirm your details and download your free guide to iOS Size Classes.

There was an error submitting your subscription. Please try again.

Unsubscribe at any time.
Archives Categories