5

I cant delete or rename current version of git... Even with sudo...

MacBook-Pro-Kiril: $ sudo rm /usr/bin/git
override rwxr-xr-x  root/wheel restricted,compressed for /usr/bin/git?

MacBook-Pro-Kiril: $ sudo mv /usr/bin/git /usr/bin/git-apple
mv: rename /usr/bin/git to /usr/bin/git-apple: Operation not permitted

2 Answers 2

10

sudo rm -rf /usr/bin/git wont work for El Capitan due to SIP restriction

simple solution is create alias

alias git='/usr/local/bin/git'

3
2

Use the below only if you want to remove the default GIT. You can still use package managers like homebrew and macports to install an alternative GIT.


The /usr/bin directory is restricted by SIP. You first need to temporarily disable it by booting to recovery, starting Terminal, and executing csrutil disable (then csrutil enable to re-enable`).

Once you have SIP disabled, you can remove git from /usr/bin.

See Also:


Note: You can check for SIP restrictions with the -Ol flags with ls. If it isn't restricted, you will see a hyphen, and if it is, you will see restricted.

2
  • 1
    While this may be a way to remove it, the OP should use a package manager such as homebrew to install a newer version instead.
    – At0mic
    Aug 3, 2016 at 22:27
  • In defense of the OP, installing a newer version isn't effective unless you change your PATH (so that /usr/local/bin precedes /usr/bin) or create a git alias as suggested by @elliot-yap.
    – John
    Apr 16, 2020 at 13:47

You must log in to answer this question.

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