Using git-svn
I am currently teaching myself how to use the git source control management system. Although it’s been a bit of a challenge wrapping my head around some of the new concepts it has been a pleasant experience learning this new tool. My goal is to eventually migrate all of my 3 SVN repositories to git, but for the time being I am still going to keep my SVN repositories around. In the mean time, I did a quick google search to see if there was anything I could to to bridge git and svn and luckily there is something!
Here is the man page for your reference! With git-svn I’ll be able to get a copy of anything in my SVN repositories, make changes and then commit these changes without having access to my server! This is great as I don’t like having my server that hosts the SVN repositories on all of the time (it’s too noisy!!). Installation of this tool in my linux box is simple, I am using Ubuntu 9.10 and all I had to do was to type in the following in a command prompt window: sudo apt-get install git-svn. Once installed, you will have to do the following steps:
- Create a working directory (i.e. mkdir test-svn-git; cd test-svn-git)
- Go into the newly created directory (cd test-svn-git)
- Type in the following command: git svn init <path_to_svn_repo>
- Next, you’ll need to fetch the files in your SVN repo: git svn fetch
- The git svn fetch command can take a a revision number (thru the -r switch) that you can use to specify what revision you want to fetch. If you want everything from your repository you can omit this switch (note: this operation my take a while if your repository is huge).
- Once you fetch the files, you’ll then be able to make changes to them and commit them to your local repository using git!
- When you are ready to push your updates to the SVN repository, type in the following command: git svn dcommit.
You’ll be prompted for a username and password (if applicable) and then each of your local commits that you did with git will be seen as a new as new revisions in SVN! Your SVN repositories will not know what you made your changes thru git. One last thing, if you want to update your current copy of the SVN repo, you will need to use the following command: git svn rebase.
Note: Some of the steps for this post came from this blog post.
Leave a comment