How to upgrade Git to latest version on Mac OS X?


I strongly recommend to not use this method anymore, you should use a package manager like Homebrew to keep the Git provided by OSX untouched. Simply install your own version of Git...

brew install git

and then update your PATH to use it instead of the genuine one. Take a look at the link in Ryan's comment below, it could be helpful.

You will be able to update Git anytime through the package manager.

brew upgrade git


Finally I found this solution from Justin Hileman to update your PATH the right way :

export PATH="$(brew --prefix git)/bin:$PATH"

Add this line in your ~/.bashrc file.

Could not symlink share/*****   /usr/local/share/**** is not writable

sudo chown -R $(whoami) /usr/local/share/

brew link git

results in: Error: Permission denied - /usr/local/lib/perl5/

sudo chown -R $USER:admin /usr/local

brew link --overwrite git