MacOS – How to run apple and custom git side-by-side

command linegitmacos

I have installed the Apple Developer Tools 5 on Mac OS X 10.9.4 which comes with Git:

git version 1.8.5.2 (Apple Git-48)

I also have installed Git 2.0.1 using the Mac OS X installer. How do I best set it up so that all applications use Git 2.0.1 by default? I could exchange the Apple Git binary for a symlink to the custom one. Alternatively I would have to modify the PATH so that it looks up the custom Git first. Is there any reason to prefer one over the other?

Also, is that even a safe thing to do? Would anything, for instance XCode, break if I replaced Apple Git with Git 2.0.1?

Best Answer

I've talked about modifying system tools before and the short of it is: don't do it! Things will use the system tools expecting a certain version of a certain tool and if you change that you could break many things.

Instead, change your path. For example, if your git is located at /usr/local/git/bin/git, add the following to your ~/.bash_profile or equivalent:

export PATH=/usr/local/git/bin:$PATH

This way, you can use your git by running git but the system git will remain available.