Working with GIT on OSX
Working with GIT on OSX is not as simple as it sounds. While there are many projects that try to deliver graphical installation procedures through DMG files for various parts of my GIT workflow, not all of the parts are available and they don’t all play nicely together. The same goes if you try to install everything from a “port” system. So this is my mix and match setup.
My GIT toolbox contains the following tools:
- GIT (http://git-scm.com/)
- GitX (http://github.com/roderik/gitx/downloads)
- Changes (hhttp://connectedflow.com/changes/)
- Terminal.app
Working with GIT and you will need some easy way to have several Terminal windows available at all times. On Ubuntu we use a quake style drop down terminal app named yakuake. A variant is available for OSX, named Visor. Installing visor is done by:
- Install SIMBL and make sure you have latest SIMBL 0.9.x
- Place Visor.bundle into ~/Library/Application Support/SIMBL/Plugins (create this directory if it does not exist)
- Relaunch Terminal.app – You should now see the Visor Status Menu Item
- Configure your keyboard trigger by selecting the Visor Status Menu Item -> Visor Preferences … and edit your keyboard hot-key
So, now we have a nice Terminal, let’s get started. I’ve found that the MacPorts project offers the a good way to install nog dmg applications. It works like apt-get or more like emerge on gentoo, because it compiles. (i know “port” is probably more like the “port” in FreeBSD, but who uses that one anyway
) Installing ports is easy, just download the dmg from this page, and install it.
After installing update the thing by running the following in a Terminal as root (sudo -i) to setup your classpath and update the port database
echo 'export PATH="/opt/local/bin:/opt/local/lib/mysql5/bin:/opt/local/lib/postgresql84/bin:/opt/local/apache2/bin:$PATH"' >> /etc/bashrc export PATH="/opt/local/bin:/opt/local/lib/mysql5/bin:/opt/local/lib/postgresql84/bin:/opt/local/apache2/bin:$PATH port -v selfupdate
Install and configure bash completion for easy access to terminal commands
port install bash-completion
echo '
if [ -f /opt/local/etc/bash_completion ]; then
. /opt/local/etc/bash_completion
fi' >> /etc/bashrc
. /opt/local/etc/bash_completion
When this is done, install git-core by running
sudo port install git-core
Now sit back, and wait…
While you are waiting you can continue with setting up Changes. Changes is a payed app, but it is the best merge tool i’ve found on OSX for now. Unfortunately it is not completely integrated with the GIT workflow but they are working on it. Download and install it from the Connected Flow website and install the terminal scripts from the Changes menu in your menubar. Afterwards we setup Changes.app like the wiki describes
Create a file named chdiffwrapper in /opt/local/bin and put this code in it.
#!/bin/sh [ $# -eq 7 ] && /usr/bin/env chdiff --wait "$2" "$5"
And edit your ~/.gitconfig (create if it does not exist) to match this one:
mate ~/.gitconfig
[pack]
threads = 0
[color]
ui = auto
[apply]
whitespace = nowarn
[alias]
cp = cherry-pick
co = checkout
ci = commit
di = diff
st = status
br = branch
mg = merge
[mirror]
summary = true
[apply]
whitespace = strip
[diff]
renamelimit = 0
external = /opt/local/bin/chdiffwrapper
[color]
branch = auto
diff = auto
status = auto
[gc]
auto = 1
[merge]
tool = chdiff
log = true
[mergetool "chdiff"]
cmd = /usr/bin/env chdiff --wait "$LOCAL" "$REMOTE"
keepBackup = false
trustExitCode = false
Now, for a GUI to manage your git repository. I personally like the free GitX app for osx. Now this version does not support pull and push commands. But fortunately the source is on GutHub and there are people who added these features to GitX. I’ve made my own fork with all these changes in it, but compiled only for Snow Leopard and in 64bit. You can download the compiled app from my GitHub downloads page. Just copy the app to your Applications folder and open your repository!


