11

I'm on OS X 10.8 and I'm using Homebrew. brew doctor tells me that I have 2 git installations, one in /usr/bin and the other one in /usr/local/bin.

Is it a bad idea to remove git from /usr/bin? If no, what's the best way to remove git and the following components from /usr/bin to only use Homebrew's?

git
git-cvsserver
git-receive-pack
git-shell
git-upload-archive
git-upload-pack
gitk
12

What's the best way to remove git and the following components from /usr/bin to only use Homebrew's?

Your shell uses the non-Homebrew binaries only because they come first in your $PATH.

So, in your ~/.bash_profile (or ~/.profile, depending on which you use), add the following line:

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

Remove all other PATH assignments that would put /usr/local/bin after $PATH, because then, /usr/bin would come first, and your shell would use the system git.


You could remove the Git installations in /usr/bin, but it's up to which one to choose. I believe at some point you used the git-osx-installer, which put it there, but there's no problem keeping both installations. You just have to know which one you want to use.

0

Apply common sense and ask yourself WHY do you want one install removed? Do you want to invoke one of those two gits everytime? Just have its bin directory in PATH first.

0

The best way is to remove it using Homebrew, because it has the record that your git was installed. If you remove it manually, during some repair process, it could install it again.

With following command check what files git package is using:

brew info --all git

Or all the files with dependencies:

brew ls --unbrewed git

The the simple way is to remove it by:

brew remove git

But it's up to you. If the git was installed by different package manager, try that one which you installed with (like port, etc.).

  • I'm afraid Homebrew won't work with sudo – there's no need to run it with root permissions anyway. – slhck Jul 28 '12 at 16:50
  • 1
    The presence of git in /usr/bin points to it being a non-Homebrew installation. – echristopherson Jul 28 '12 at 23:45
  • I'm using brew with sudo, but it depends of your configuration. – kenorb Jul 29 '12 at 0:31
0

Because of the "/usr/bin/git" is installed by apple git-48, so I prefer DO NOT change the PATH. You could do something like following:

$ brew update
$ brew install
$ sudo mv /usr/bin/git /usr/bin/git-48

Then you can check it by

$ git --version

The output will be like this: git version 2.1.0

BTW, if you want to install vim by homebrew, it also works.

0

How to remove the git installation from /usr/local/bin on a Mac. (OSX 10.14.2)

I had an old 1.9.0 git installation from an git-osx-installer package (git-1.9.0-intel-universal-snow-leopard.dmg). Here's how I removed it.

Fist, find your git version and install location.

$ which git
/usr/local/git/bin/git
$ git --version
git version 1.9.0

Then, find your original git installer package, in my case git-1.9.0-intel-universal-snow-leopard.dmg. If you don't have it download from here: https://sourceforge.net/projects/git-osx-installer/files/

Finally, open the installer package (git-1.9.0-intel-universal-snow-leopard.dmg), and run uninstall.sh file in the root folder.

$ uninstall.sh

DONE

Attaching the uninstall.sh file, which shows the file paths being deleted. The uninstall script may be different for different installer versions, so be sure to use the correct one.

uninstall.sh file (git-1.9.0-intel-universal-snow-leopard.dmg)

if [ ! -r "/usr/local/git" ]; then
  echo "Git doesn't appear to be installed via this installer.  Aborting"
  exit 1
fi
echo "This will uninstall git by removing /usr/local/git/**/*, /etc/paths.d/git, /etc/manpaths.d/git"
printf "Type 'yes' if you sure you wish to continue: "
read response
if [ "$response" == "yes" ]; then
  sudo rm -rf /usr/local/git/
  sudo rm /etc/paths.d/git
  sudo rm /etc/manpaths.d/git
  pkgutil --packages | grep GitOSX.Installer | xargs -I {} sudo pkgutil --forget {}
  echo "Uninstalled"
else
  echo "Aborted"
  exit 1
fi

exit 0

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.