If you are programming, and you are still not using any form of version control, you really have no excuse. There are many benefits to being able to keep track of your code and try out various branches, even if you are the only programmer in the project. If you are collaborating with someone, it soon becomes nearly impossible (or at least very time-consuming) to deal with various versions and changes.
Of all the version control systems I’ve tried over the years (CVS, Subversion, a little bit of Mercurial, and Git) it seems that Git has “won” in a sense. There is a sizable open-source community born around GitHub (and Bitbucket) for which Git works very well indeed. Also many programming tools have built-in or plug-in support for Git, so you don’t even have to use command-line tools for managing your source code repositories if you don’t want to.
For open-source development, GitHub is the obvious choice. If you’re doing closed source, or you think your code isn’t ready for public scrutiny, Bitbucket gives you unlimited private repositories. I’m currently using GitHub to collaborate on some private repositories, which you can get with a paid plan, and Bitbucket for my closed-source app projects.
In a spirited attempt to really learn to use the tools of my trade, I wanted to take some time to better learn Git for version control (and also dive deeper into Xcode, but that is another story).
Earlier I’ve occasionally been using the fine tome Version Control with Git, 2nd Edition* by Jon Loeliger and Matthew McCullough to learn the basics, but I wanted to really dive in. I’ve already mastered the very basics, and have also used remote repositories with both GitHub and BitBucket, but there is a lot more to learn to be able to really take advantage of Git.
* Disclaimer: I’m an O’Reilly affiliate, and the links above take you to the O’Reilly online bookstore, in the hope that you purchase something, so that I will get a small commission.
Another book about Git, which I’m not intimately familiar with, is Pro Git by Scott Chacon, available to read online for free. Since it is endorsed by the Git web site, I’m betting it’s also worth your time.
Update @ T + 2h: For a quick online introduction to Git and GitHub, even if you’re not primarily an application developer, read the git/github guide for statistical/computational scientists, by Karl Broman. After all, Git is not just for source code!
Since I’m primarily a Mac user, one shortcoming of _Version Control with Git_ is the lack of specific guidance about using Git on OS X. Being UNIX-based, OS X is a similar enough platform for using Git to the Debian and Ubuntu systems described by the authors. It’s the maintenance of Git or OS X which is a bit different.
It seems that Git still doesn’t come as standard with OS X, but when I started writing this, I did have Git 1.8.4 installed on my Mac running OS X Mavericks, in
$ which git
It could have been ended there by installing the Xcode Command-Line Tools, or I may have installed it separately. Embarrassingly, I have no recollection of that.
As it happens, Git 2.0 was just released less than a week ago; to find out what’s new, go read the Atlassian Developer Blog entry “It happened: Git 2.0 is here and it’s full of goodies“.
Since I increasingly use the excellent Homebrew package manager, I checked to see if there was a Git 2.0 package already, and sure enough, there it was:
$ brew info git
git: stable 2.0.0 (bottled), HEAD
So I promptly proceeded to install it:
$ brew install git
It went mostly fine, but at the end I got an error about Perl, and Homebrew also told me that it couldn’t symlinked Git to
/usr/local, apparently because I had GitHub for Mac installed in
/Applications. (Homebrew is really great in keeping you from screwing up your system and in documenting the reasons.)
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
You can try again using:
brew link git
Possible conflicting files are:
/usr/local/bin/git -> /Applications/GitHub.app/Contents/Resources/git/bin/git
Actually, that must be where the
git executable came from. It seems like I would need to choose between the GitHub Mac app, which I don’t often use, and the latest command-line Git. I really didn’t want this to turn in to an all-day packagefest, so I decided to skip updating Git for now. Most likely it won’t be long now until the official GitHub Mac app will be updated for Git 2.0.
In the meantime, I’m going to dive deeper into Git, somewhat conservatively using version 1.8.4. For basic Git gymnastics, it’s just fine.
If you’re just starting with Git, it can seem like a long way from your first commit to managing a remote repository and generating SSH keys, but take baby steps. Good books are worth their weight in gold; the time invested in them is reaped in productivity, which comes through really understanding what you’re doing, and why you’re doing it.