Updating git in Mac OS X Lion

I’m about to start a new Rails project. But before diving in and start coding I decided to check the tools I have installed and I noticed git is slightly outdated so I decided to install a more up-to-date version.

Researching on the web for the best way to do I could not find one that would uninstall the older version and install the one. Some posts said I needed to remember how I installed and had suggestions on how to uninstall it from there. I can’t remember how I installed, so I decided not to uninstall it.

Also, I believe that when I installed Xcode, git was installed with it as git is now Xcode default source control. Another reason not to touch the installed version of git, I mean there might not be any issues but better be safe than sorry. (I learned something from replacing the default Mac OS X ruby 1.8 and with ruby 1.9 and breaking some stuff.)

So, I went ahead and installed git through Homebrew. However, after the installation was finished, I was still having problem reaching the right git version.

I took a look at the /etc/paths file and noticed that directory /usr/local/bin was the last in the path list and considering Homebrew installs stuff in /usr/local/share but creates symlinks in /usr/local/bin you just need to make sure you are pointing to that directory in your path. Thus, I moved /usr/local/bin to the top of the list in the /etc/paths and voilà the newest version of git started being picked up.