Getting To Know Git
Mark Cornick, Former Viget
Article Category:
Posted on
If you're a developer paying attention to recent trends, it's hard to ignore the recent surge of interest in distributed software configuration management (SCM). Many of us are familiar with "client-server" SCM systems like Subversion or CVS. Distributed SCM systems work more like peer-to-peer networks. Each developer maintains a separate, full-fledged repository. Revisions can be shared with other developers by pushing them to, or pulling them from, other repositories. You can work independently of any centralized repository (especially nice if you're not connected to a network.) If a public repository is available for your favorite open-source project, but you haven't gained commit rights, you can still make your own changes, track them in your own repository, and contribute patches back to the project.
Git is a distributed SCM system that has attracted a lot of attention recently. Git was written by Linus Torvalds for revision control on the Linux kernel source code, and has since been adopted by a number of projects. Several of us here at Viget Labs have tried Git recently and had much success. It's not the only distributed SCM out there, but it's one that we like enough to adopt for some of our work.
If you're using an up-to-date Linux/BSD distribution or an OS X packaging system such as MacPorts, you likely have a Git package available to install - look for a package called "git" or "git-core". If not, the Git source compiles and installs easily (unless you're on Windows, which requires some effort we won't get into here). From there, the Git tutorial and Everyday GIT will help get you started. For those of us who are used to Subversion, there is a Crash Course which helps you learn the Git commands corresponding to your familiar Subversion operations. (There's even a git-svn conduit to allow you to keep a Git repository in sync with a Subversion repository, effectively allowing you to use Git as a frontend for Subversion.)
Since each developer's working copy is a bona fide Git repository, there are multiple possibilities for working with Git. In a larger team setting, you might actually prefer an approach similar to client-server systems, where you maintain one "master" repository which each developer pulls from and pushes to. For a small team (say, two or three developers) it may be effective to have each developer pull changes from, and push changes to, each of the others directly. And if you're a solo developer, then one Git repository on your development machine is likely all you need.
Git works well with other tools you may have in your toolbox. Git support in Rails' code generators was recently added to edge. A Git bundle for TextMate is under way. Capistrano supports Git starting with the most recent release (2.1.0.) And if you're using Viget's rsync strategy for Capistrano, we've just updated it to work with Git. You can expect to see more support for Git in other tools as it gains popularity.
If distributed SCM interests you, give Git a try. It's easy to get started, and quite powerful once you get the hang of it.