Migrating Version Control from Subversion to Git
9 December 2009 | 0 comments | Tagged as: Git Subversion
Recently at work we have moved over from using Subversion as our Version Control System to Git. We made this change for several reasons:
- Branching and merging between branches is much easier in Git.
- Git is a distributed version control system. Every working copy is a repository its own right and therefore hold a full development history of the project. The remote server can go down without the problem of having to restore from a backup.
- Git is very fast compared to Subversion.
- Git is cool.
The procedure from migrating over from Subversion to Git is fairly straightforward.
Firstly we will install Git on our local machine and the remote server where we intend our repository to be located. On Debian we would type the following command:
$ apt-get install git-core git-svn
We have now installed the core Git package together with a package that provides tools for interoperating with subversion repositories, and importing SVN development history. Now on our remote server we will create our directory structure to hold our repositories:
$ cd /var
$ mkdir git
Each Git directory is its own full repository. Our next step is to create a new empty repository for our project and initialise it.
$ cd git
$ mkdir project.git
$ cd project.git
$ git init
We now have a repository ready and waiting for us to transfer our existing Subversion held project into. To do this we will use the Git-Svn tool. This will allow us to initialise a new local Git repository from our Subversion repository and checkout the project into it. Make a local working directory, change into it and then initialise a the new local Git repository:
$ mkdir git
$ cd git
$ git svn init svn+ssh://svnuser@machinename/var/svn/repos/project
Then issue the following command to actually get the files from the Subversion repository and put them into your local Git repository:
$ git svn fetch
Now we need to tell our local repository the location of the repository on the remote server called 'origin'.
$ git remote add origin gituser@machinename:/var/git/project.git
We also need to configure Git to sync our main branch so the pull operation will automatically merge the remote master with your local master, when both contain new code. we can do this as follows:
$ git config branch.master.remote origin
$ git config branch.master.merge refs/heads/master
Finally we push all the files from our local Git repository to the remote one
$ git push origin master
Once all the files are in the remote repository we can clone it locally as follows:
$ git clone ssh://gituser@machinename/var/git/project.git
POST A COMMENT
Markdown available. Required *.











