Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

upgrade Git on Mac

I have previously installed Git(1.9.3) and I want to upgrade it to the latest version(2.0.1). I uninstalled the previous install by running the uninstall.sh first and then git.pkg. However, when I run git --version, it still shows me git version 1.9.3 (Apple Git-50).

So I did this:

$ which git
/usr/bin/git

$ echo $PATH
...:/usr/local/git/bin

Obviouslly, Git in /usr/local/git/bin is the latest version I want.

So how can I remove the path of the older version and tell Mac OSX where to find the right version?

Thanks!

like image 504
wking Avatar asked Dec 03 '22 18:12

wking


2 Answers

One solution would simply to change the order in your $PATH in your ~/.bash_profile

export PATH=/usr/local/git/bin/:$PATH
source ~/.bash_profile

As suggested in git: command not found (on OS X 10.5) and Locate Git installation folder on Mac OS X.

In your case, you do have /usr/local/git/bin/ in your PATH, but in the wrong order if you want it to be taken into account.

like image 159
VonC Avatar answered Dec 11 '22 17:12

VonC


XCode uses its own git version, which makes it a bit difficult to update. These two terminal commands worked for me:

sudo mv /usr/bin/git /usr/bin/git-xcode
sudo ln -sf /usr/local/git/bin/git /usr/bin/git

This solution is taken from Heroku's recently published seurity alert for git 1.9.3. This post includes a download link. These two commands are advised in that link. The .dmg download package also includes a README file with a similar link.

like image 36
Tal Yaniv Avatar answered Dec 11 '22 16:12

Tal Yaniv