Homebrew, spotlight and upgrading software under /usr/bin/

1

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.

  1. Can I use Homebrew to upgrade this version? Or would Homebrew install git in a separate location?

If Homebrew installs git in a separate location:

  1. How would my terminal know which version/location of git to run? Was I supposed to update PATH in my shell after installing brew?

  2. How would Spotlight know which version/location of Git to use?

Amelio Vazquez-Reina

Posted 2014-01-29T14:39:23.397

Reputation: 5 686

Answers

2

Can I use brew to upgrade this version?

No. That is the default version installed by Xcode / developer tools. I would leave it as-is.

Or would brew install git in a separate location?

Yes, in /usr/local/bin/git, which links to a version installed in /usr/local/Cellar.

(Note that unlike Homebrew, the official OS X Git Installer installs to /usr/local/git/bin.)

How would my terminal know which version/location of git to run? Was I supposed to update PATH in my shell after installing brew?

Typically you don't need to because Homebrew by default does not ship anything that comes with OS X anyway. But if you want Homebrew commands that are duplicates of native commands to come first, edit your PATH in your ~/.bash_profile:

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

After a restart of the shell or re-sourcing the path, the git should come from Homebrew. Run which -a git to see all installed Git binaries.

How would spotlight know which version/location of git to use?

I'm not sure what the purpose would be, since Spotlight is used for finding documents that can be opened in some application—or GUI applications—but git by itself cannot be opened.

I suspect that Spotlight does not find any of the git executables unless they exist in your user's home directory, e.g. ~/bin.

slhck

Posted 2014-01-29T14:39:23.397

Reputation: 182 472