34

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.

9
  • cd /usr/bin then ls -l and post results please?
    – emotality
    Commented Jun 27, 2016 at 9:48
  • @emotality Thanks, I've added it. Let me know if you need anything else.
    – Dambo
    Commented Jun 27, 2016 at 9:58
  • Which answer suggested removing it? It needs to be heavily down voted as it is not a good idea.and you should not install git in /usr/bin/git (in fact doing that is quite difficult so how did you manage it)
    – mmmmmm
    Commented Jun 27, 2016 at 10:08
  • If the question you saw was apple.stackexchange.com/questions/146503/… note that that git us not in /usr/bin/git and there is a directory which in your case you have apple's got and there is not git directory
    – mmmmmm
    Commented Jun 27, 2016 at 10:30
  • @Mark I forgot to add the link, but that's exactly the question I am referring to. I am not sure why I have the wrong directory, it is possible that updating to El Capitan might have changed something in the git location? Anyway, given I have git in the wrong directory I am not sure I understand your recommendation on how to fix it.
    – Dambo
    Commented Jun 27, 2016 at 12:46

4 Answers 4

39

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.

2
  • This seems to be true, I didn't uninstall the git which was installed in usr/bin but when I installed git with homebrew it took over. Commented Aug 14, 2021 at 16:36
  • 1
    The git app in /usr/bin/git was failing for me asking to install the command line tools every time (even after it was already installed a couple of times). I also did not want to install XCode because I don't use it anymore. I then opened the Finder in the Applications folder and moved the Xcode.app to the Bin and now my git app does not ask me to install things anymore. Commented Sep 14, 2022 at 11:42
20

For people who installed git by following instructions on the official Git homepage, and therefore have git installed at /usr/local/bin/git, run the uninstall script:

/usr/local/git/uninstall.sh

5
  • 1
    How does this uninstall /usr/bin/git?
    – nohillside
    Commented Apr 29, 2019 at 15:17
  • @nohillside It doesn't, because git-scm.com does not install to /usr/bin/git. Updated the answer to make that clearer.
    – Kasper
    Commented Apr 29, 2019 at 15:30
  • Thanks. If you are wondering about the downvotes, please reread the question. While your answer is correct in itself, it doesn’t directly address the question asked.
    – nohillside
    Commented Apr 29, 2019 at 15:38
  • @nohillside I'm aware, but it does answer the title, and the title is the reason I clicked the article - So this answer would've helped me :)
    – Kasper
    Commented Apr 29, 2019 at 15:49
  • Thanks a lot this was my problem too ... homebrew insisted I had 2.39 already installed but which git showed this version 2.15. Uninstalling as you suggest seems to have fixed things Commented Jan 26, 2023 at 18:47
2

/usr/bin/git, along with some other cmd tools, is just a jumper binary to a real binary comes with Xcode.app or 'Xcode Command Line Tools' (CLT). It is protected by SIP and you shouldn't delete it.

You might consider to remove Xcode.app or /Library/Developer/CommandLineTools/ .

1
  • Excellent. I'm guessing this is the binary that's responsible for the pop-up offering to download the CLT package? Commented Feb 28 at 17:30
0

I had a very similar issue. Struggled with it for hours and finally found that removing/deleting my .ssh folder and generating a new ssh key did the trick.

I ran the following in the terminal

rm -rf .ssh/

(after rm -rf, type .ss and hit TAB, it should jump to the folder)

Your ssh folder should no longer exist

Next, generate your public key with the following command

ssh-keygen -t rsa

OR, if you want to set it up with your email address, you can type

ssh-keygen -t rsa -C "[email protected]"

This will generate a ssh key

(Go through the process by following the prompts, set password if needed)

Then, you can display your code by typing the following

cat .ssh/id_rsa.pub

OR

pbcopy < ~/.ssh/id_rsa.pub

(to automatically copy your public key)

Finally, paste it in your GitHub or any other, as you would normally add a public ssh key.

This worked very well for me.

I hope it helps a few others as well

1
  • 4
    This is a interesting answer, but I'm not sure how it relates to removing git Commented May 17, 2019 at 22:47

You must log in to answer this question.

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