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.

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

1 Answer 1

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.

2
  • Great! Thank you for this comment, exactly was I was after. BTW, how do I set the PATH as you described? Commented May 18, 2020 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
    Commented May 18, 2020 at 22:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .