0

I hope the title isn't confusing, but I seem to have accumulated a couple of different versions of git in various directories over the years. I'd like to clean it all up and just have one version, and set that as the default.

whereis git gives me /usr/bin/git, which git gives me /usr/local/bin/git.

I've got another version under /usr/local/Cellar/git (version 2.16). Installed with Homebrew I guess

Then there's /usr/local/git (version 2.10) which is what what I get with git --version on terminal.

  • 1
    Is any of them a sym-link to the other? – Harcker May 13 at 17:27
  • I don't know. How do I check? – Shiny_and_Chrome May 14 at 4:26
0

You have a couple different versions of Git. One is /usr/bin/git, which is shipped with the system and is a wrapper around XCode's version. Since you're using Homebrew, XCode (or at least its developer tools) is required, and you have Homebrew's version in /usr/local/bin/git.

The files under /usr/local/Cellar are the places that Homebrew stores files, and they will update automatically if you use Homebrew. You should not modify or delete those files except by using the standard brew methods.

It's possible that you also have the prebuilt Git packages for macOS installed under /usr/local/git. These are a little out of date, so you're probably better off getting rid of that directory and using Homebrew's instead, which is almost always the latest and most up-to-date version.

In order to use Homebrew's version over /usr/bin/git, set your PATH in your shell configuration to have /usr/local/bin before /usr/bin, and you'll use Homebrew's version automatically.

| improve this answer | |
  • Great! Thank you for this comment, exactly was I was after. BTW, how do I set the PATH as you described? – Shiny_and_Chrome May 18 at 10:08
  • You'd edit your ~/.bashrc or ~/.zshenv (depending on your shell) and write something like export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin (depending on what you want to set it to). – bk2204 May 18 at 22:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.