For the past year I have been using subversion to control my code for various projects including this web site. However, an open source project I worked on recently uses git. For this reason I printed off the manual and got to work. Here is a quick look at some of the high points:
The biggest difference between Git and subversion is the distributed model. With subversion there is one repository and everyone merges with it, but with git everyone has their repository locally. This means that the main method of collaboration moves away from everyone syncing with one server, to the idea of pulling code from other people. When someone gets some work done that you want, you simply write a command to grab the changes from their server. This allows you to take what you want and leave what you don’t. Your local copy has only the changes that you want.
Torvalds argues that this model works much better for development because it works off trust. Instead of having to the take the code of anyone who has access to the repository you can choose to only take work from people that you trust.
Having a fully functional working repository locally on my machine is a huge improvement to what I was doing with subversion. Unlike subversion, when you create a “working copy” it is a fully functional repository. With svn if I wanted to commit some code, I had to wait to connect to my server first. With git, I do all my committing locally, and if I want to push to a server, I can.
In the development process a branch is very important. It allows you to have the freedom to go off and make big changes with the safety net that there is a working branch waiting for you if you need it. However in subversion, this was not an easy or intuitive process, it involved copying files into a branches folder, which would then be shared with everyone who connects to the server.
In git since all your branches are local, you can easily create a branch without worrying how it effects other people you are working with. Also there is no complicated directory structure. Git keeps track of all of your changes and when you change branches it changes the files for you. This means that when I change branches, my text editor really doesn’t know a difference, except the code and files change properly.
After a simple 3 hours learning git, I felt more comfortable with it than I ever did with subversion. Since then, I have changed all of my projects to work with git, and hope I don’t have to touch svn again.