1

I want to update git. I find this article:

On one of the first steps, I get a problem. When I tried to backup currently installed git I got permissions restriction. It's ok it must be some OSX system restriction.

I checked PATH and noticed that /usr/bin is after /usr/local/bin. So if I just install new version of git via brew this version will be used (since brew installs everything into /usr/local/bin. I did that and the result frustrated me. Old git is using instead of installed via brew. Why?

Here is some output:

svlad at sharikovvlad in ~/sandbox/git-test on master [+]
$ git --version
git version 2.11.0 (Apple Git-81)

svlad at sharikovvlad in ~/sandbox/git-test on master [+]
$ which git
/usr/local/bin/git

svlad at sharikovvlad in ~/sandbox/git-test on master [+]
$ ls -al /usr/local/bin/git | grep git
lrwxr-xr-x  1 svlad  admin  28 Sep  3 18:16 /usr/local/bin/git -> ../Cellar/git/2.14.1/bin/git

svlad at sharikovvlad in ~/sandbox/git-test on master [+]
$ /usr/local/Cellar/git/2.14.1/bin/git --version
git version 2.14.1

svlad at sharikovvlad in ~/sandbox/git-test on master [+]
$ echo $PATH
/Users/svlad/bin:/usr/local/opt/gnupg@1.4/libexec/gpgbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Frameworks/Mono.framework/Versions/Current/Commands
$

So why apple git is using? /usr/local/bin is first in path so symlink from this folder must be used? So why I am getting old version?

Also, any thoughts how can I remove apple git?

  • 1
    "On one of the first steps, I get a problem. When I tried to backup currently installed git I got permissions restriction. It's ok it must be some OSX system restriction." Yep—it's called System Integrity Protection and it prevents you from modifying certain system files, including anything in /usr/bin. You could just disable SIP and delete or replace /usr/bin/git—although that's really not a good solution. – Wowfunhappy Sep 3 '17 at 18:13
  • Have you tried a new terminal or rebooted sinc installing the homebrew git? – Mark Sep 5 '17 at 2:40
  • @Wowfunhappy Hi! Thank you for your response! Yep it is not good solution at all. – Sharikov Vladislav Sep 5 '17 at 9:32
  • @Mark Yes I restarted mac many times after installing homebrew. – Sharikov Vladislav Sep 5 '17 at 9:33
  • Actually why I can not remove is not the question. The main question is why OS choose git from /usr/bin instead of /usr/local/bin? local dir is on the left and as I know macos try to find command in each dir in PATH and it is going from left to right. So git in /usr/local/bin should be resolved firstly. Why git from /usr/bin is used then? – Sharikov Vladislav Sep 5 '17 at 9:35
1

You can try to remove CLI tools alone, which is what comes with Apple git and that may solve your problem.

CLI Tools Removal

if that didn't do it, that means that CLI Tools were downloaded separate from Xcode and you can try this to remove it:

sudo rm -rf /Library/Developer/CommandLineTools

Once that's gone you just check to make sure it got removed and then reinstall it with Homebrew. Hope this may help.

You must log in to answer this question.

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