MacOS – Homebrew – Upgrading software in /usr/bin

githomebrewmacos

My OS X comes with a version of Git installed in /usr/bin. However, this version is older than the official stable one. I would like to upgrade it.

Can I use Homebrew to upgrade this version? Or would Homebrew install Git in a separate location (and if I do so, how can I ensure that the new version is actually used)?

Best Answer

Don't replace, modify or rename the system tools in /usr/bin. There are a number of reasons why this is a bad thing, and you can search for the specific reasons, but to be simple, don't edit the system versions.

Homebrew knows this, and that's why it stores the tools in /usr/local/bin. This version is used instead of the system version since Homebrew requests that its directory be before the system path in the $PATH variable.

Run brew doctor and you'll probably get a message like this:

Warning: /usr/bin occurs before /usr/local/bin This means that system-provided programs will be used instead of those provided by Homebrew. The following tools exist at both paths:

easy_install
easy_install-2.6

Consider amending your PATH so that /usr/local/bin is ahead of /usr/bin in your PATH.

To fix this, either add this to your profile:

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

…or add /usr/local/bin to the top of /etc/paths, such as:

/usr/local/bin
/usr/local/sbin
/usr/bin
/bin
/usr/sbin
/sbin