How do I upgrade git on Mac OS X?

Solution 1:

None of the current answers will upgrade Xcode git. They will only install a newer version of git.

Xcode has changed its mind several times about the best git location. Depending on how long ago you have been installing Xcode you will see git binaries at:

/usr/bin/git
/usr/local/git
/Applications/Xcode.app/Contents/Developer/usr/bin/git
/Applications/Xcode.app/Contents/Developer/usr/libexec/git-core/git

Even if you update the PATH, Xcode will stick to its version. The only way I know to force it to use the newer version is replacing those git binaries by a link to the new one you installed.

ln -s /opt/local/bin/git /usr/bin/git

Repeat for the other path. Notice I use a symbolic link, not a hard one. Otherwise Xcode would replace your other installation during an upgrade

Solution 2:

You can install git from source using Homebrew, and just point your PATH to use the new one instead of the xcode/system version.

There's a little video tutorial here. http://vimeo.com/14649488

It's for an older version but it will get you started, let me know if you need more info.

(You can also use MacPorts, Fink or the Git OS X installer, to upgrade.)

Solution 3:

If you want to use git itself to update git run the following commands :

This can be run from anywhere git clone git://github.com/gitster/git.git then you want to cd git then run this sudo make prefix=/usr install install-doc install-html install-info

This will install Git into your /usr/bin folder for global use.