Use downloaded Git instead of preinstalled Git

I am following the Lynda.com Git Essential Training. After he downloads and installs Git he enters which git and gets /usr/local/git/bin/git However when I do it I still get the preinstalled path /usr/bin/git

How do I change the path so I am working with my downloaded version of Git

I am using a Macbook Air - Mavericks - OS X 10.9.4 and followed the default install instructions.


Solution 1:

Add the following to your ~/.bash_profile

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

Solution 2:

I use Homebrew, then install git using Homebrew. This makes sure that git stays on my path, and makes it easy for me to keep git up-to-date, as well as making it easy to install other software, with its dependencies.

To install things with Homebrew, you first need to install the Xcode Command Line Tools. StackOverflow has a great answer on installing the command line tools on OSX 10.9.

After you have installed the Xcode Command Line Tools, you may notice that there is a git command you can use: see Does installing Command Line Tools for Xcode also install Git? That is not the Homebrew version of git, so it doesn't track updates.

Next, go to http://brew.sh and follow their directions for installing Homebrew. That will install git into the Homebrew directory, and link git to /usr/local/bin/git. /usr/local/bin should end up on your PATH before /usr/local/git, so you will end up using the Homebrew version of git.

After that, you can install anything for which Homebrew has a formula, including the latest versions of git. Use brew update to keep your index of available packages up to date, and brew doctor to verify that your Homebrew configuration is correct. Then you can use brew upgrade git to keep your git at the latest version available to Homebrew.