Removing git from /usr/bin
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 5 Answers
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:$PATHRemove 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.
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.
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 gitOr all the files with dependencies:
brew ls --unbrewed gitThe the simple way is to remove it by:
brew remove gitBut it's up to you. If the git was installed by different package manager, try that one which you installed with (like port, etc.).
3Because 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.
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.0Then, 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:
Finally, open the installer package (git-1.9.0-intel-universal-snow-leopard.dmg), and run uninstall.sh file in the root folder.
$ uninstall.shDONE
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