Who are you calling a Git? When I say ‘Git’, I don’t mean the British derogatory term that was immortalized by the TV show Red Dwarf. I mean of course the latest generation of revision control systems, designed by Linus Torvalds for use on the Linux kernel. You can read up on the history of Git at its Wikipedia entry — but what you really need to know is that it is quickly becoming as popular as SVN and CVS and is being used for many open source projects. Thus if you have a need to obtain source from git, or contribute to a project being stored in a git repository, then you will need to install git.
There are a few ways to get the base Git package (with the Git command-line client and two basic graphical frontends) installed under OS X, including compiling the source-code yourself, or installing it via MacPorts. However the easiest is by simply downloading and running the Git os x installer, which will do everything for you.
Once Git is installed, you can quickly create a local Git ‘clone’ of a source repository such as VLC’s, by opening a terminal window, navigating to the directory you’d like the source to exist and then typing
git clone git://git.videolan.org/vlc.git. Once you have your local clone, you can make your changes and stage commits back with the command-line client. To find out all the power and functionality of Git, you can read the tutorials and detailed documentation that’s available at Git’s official webpage.
As Git is quite new, there are not many UI front-ends available yet, and even less specifically for OS X — with none of them being very mature. However, I’ve compiled a list of six tools/apps for managing Git on OS X. The two native OS X apps (GitX and GitNub) should be watched carefully over the next year or so, as they could turn into some excellent software.
GitK comes with the command-line git client and is a tcl/tk application that lets you browse the history of repositories. This can be launched by typing
gitk in a terminal. It’s not pretty, but it does the job and serves as a reference for future clients.
Git Gui also comes with the command-line client and is likewise also a tcl/tk application. This lets you perform staged commits on your code and can be launched by typing
git gui in a terminal. Note the space between the two words, tab-completion on the terminal will not find this, but it is there. While the UI is more appealing than GitK, it leaves a lot to be desired when one is used to the Aqua and Cocoa UI.
GitX is an attempt to bring OS X’s shiny interface in all its glory to the functionality of gitk and git gui. It currently allows viewing revision history and committing files. You will need to make your local clone manually with the command-line client first, then you can open the cloned directory and use the UI to browse and commit.
GitNub is another OS X specific client being written in CocoaRuby. Its not yet officially released and the only way to get it running is by compiling it yourself by cloning the git directory and building it in XCode. Once built and pointed at a local git repository, it allows browsing the various history. Where this goes in the future could be interesting.
OpenInGitGui is an AppleScript extension to Finder that simply enables you to quickly and easily open the current clone in Git Gui without having to manually launch it from a terminal. After installing the compiled AppleScript, you then just drag it onto Finder’s toolbar to create a new tool button. Once you navigate to a local Git clone, you can just click the button to make Git Gui launch.
There is a Git plugin for the cross platform IDE Eclipse that works under OS X. This is impressively functional with the ability to clone a Git repository and import it directly as an Eclipse project. It then lets you browse history, perform comparisons and diffs and do commits. If you use Eclipse, this is an ideal solution.
Git is still very new, and as it grows in popularity, the number of clients supporting it will also grow. Stay tuned to TheAppleBlog for news and updates on using Git with our favorite desktop environment.