Working with git on Mac OSX "Snow Leopard"
Working with GIT on OSX is not as simple as it sounds. While there are many projects that try to deliver dmg files for various parts of my GIT workflow, not all of them are available and they don't all work together nicely. 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/)
- qgit 2 (http://repo.or.cz/w/qgit4.git)
- kdiff3 (http://kdiff3.sourceforge.net/)
- 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 good 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
sudo port -v selfupdate
When this is done, install git-core and qgit by running
sudo port install git-core qgit
Now sit back, and wait... Ports will compile QT etc, so it will take a few hours
While waiting, you can continue with kdiff3. Kdiff3 is a three-way diff viewer and mergetool. You see a lt of tutorials for OSX that use FileMerge that is part of the Xtools, but this is not a three-way merge application, and i found the interface and usability not good enough. Download the OSX version of kdiff3 from the website and install it. Why not compiling it with ports? Well because when starting the commandline version, you get some strange X window icon in the dock and no kdiff3.
Working with GIT on the commandline, you will need to be able to let GIT access kdiff3 through the mergetool command. This means a commandline version needs to be available. We do this by creating an alias command in /usr/local/bin that forwards to the kdiff3.app
sudo mate /usr/local/bin/kdiff3 sudo chmod a+x /usr/local/bin/kdiff3
The content of tis file is listed below:
#!/bin/sh exec /Applications/kdiff3.app/Contents/MacOS/kdiff3 "$1" "$2" "$3" "$4" "$5" "$6"
One more tweak is required, you need to configure git to use kdiff3. You can do this using the git commandline or take the config below. This config has a lot more useful tweaks then just the mergetool, i suggest you start from 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
[pager]
color = true
[status]
color = auto
[color]
branch = auto
diff = auto
status = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
new = blue bold
[color "status"]
added = yellow
changed = green
untracked = cyan
[gc]
auto = 1
[merge]
keepBackup = false;
tool = kdiff3
log = true
[diff]
color = auto
renamelimit = 0
Comments [0]