How to uninstall Git from the command shell

git

I currently have installed

git --version
git version 2.7.4 (Apple Git-66)

At this path

which git
/usr/bin/git

In a previous answer
How to uninstall Git?
it was suggested to run the uninstall.sh, but if I run cd /usr/bin/git I get -bash: cd: /usr/bin/git: Not a directory.

Below I copied the output of ls -l on the directory usr/bin (only the files that look to me as related to git for reasons of space).

    -rwxr-xr-x   1 root   wheel     18176 Mar 12 09:08 git
    -rwxr-xr-x   1 root   wheel     18208 Mar 12 09:08 git-cvsserver
    -rwxr-xr-x   1 root   wheel     18208 Mar 12 09:08 git-receive-pack
    -rwxr-xr-x   1 root   wheel     18192 Mar 12 09:08 git-shell
    -rwxr-xr-x   1 root   wheel     18208 Mar 12 09:08 git-upload-archive
    -rwxr-xr-x   1 root   wheel     18208 Mar 12 09:08 git-upload-pack

How do I uninstall git? I am trying to update to a newer version, the installer runs successfully, but when I run git --version I still get the older version. Thus I was thinking to uninstall git and reinstall from scratch, not sure if this is the right approach tho.

Best Answer

Do not uninstall Apple-distributed Git. You can leave it as it is and run another version by having it in a directory earlier in PATH environment variable.

The easiest way to install another version on OS X would be to use Homebrew packet manager.

After installing it, you can run:

brew install git

Homebrew (brew) will take care of all dependencies and configure the latest Git version, however there is still a chance it will find a setting it cannot resolve automatically, so read what Homebrew says at the end.

Packages installed with brew do not interfere with system-preinstalled packages. It installs packages under /usr/local/Cellar directory and puts executables in /usr/local/bin, so you just have to keep it in PATH variable in before /usr/bin.