Having decided to try out Git, I was excited to learn that Git could interface with Subversion repositories via git-svn. git-svn provides a bidirectional flow of changesets from a branch of a Subversion repository and any number of branches in a Git repository. The problem that I soon encountered should be evident from this description—you inherit the limitations of the Subversion repository. A rewrite of a paper for the European Journal of Philosophy provided the opportunity to start a Git repository and work purely with Git. This was a revealing exercise that allowed me to shed some habits engrained from being a long-time Subversion user.
I am now in the process of transitioning my work over to Git. One salient difference is that, with Subversion, I kept all my mission-critical text files in a single structured directory; Git, however, wants to find relationships among everything in the repository, so it is important to keep unrelated projects in different repositories. (Fortunately setting up Git repositories is a snap.) This is important to bear in mind when migrating from Subversion. If, like me, you maintained a single Subversion repository with separate subdirectories for each of your projects, you need to migrate each of these into separate Git repositories.
Here is how I began my migration.
I decided to start with my remind files:
$ mkdir -p /tmp/remind
$ cd !$
$ git-svn clone http://markelikalderon.com/svn/TheHub/Remind --no-metadata
The command:
calls init, which creates a new Git repository, and fetch, which fetches the contents and history of the directory. git-svn clone takes the options of both init and fetch. One useful option is –no-metadata which strips out the no longer needed Subversion metadata.
Now I needed to configure my new Git repository. I began by creating a file and opening it in my text editor, TextMate:
$ touch ~/users.txt && mate ~/users.txt
I then added the following to users.txt:
‘kalderon’ being my Subversion user name and ‘PhilGeek’ being my Git user name. There should be one line each with this syntax for each of the users. Now I was ready to configure git:
% git config svn.authorsfile ~/users.txt
The final step is to clone this new Git repository to rid ourselves of any remaining svn cruft. I created a new GitHub project and then within the Git repository:
$ git remote add origin git@github.com:PhilGeek/remind.git
$ git push origin master
Finally, I cloned the remote repository into the directory where my remind files were to live locally and deleted the /tmp/remind directory.
Not too bad. But you might consider automating the process with a shell or ruby script, if this needs doing several times over.
Post a Comment