14

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.

  • cd /usr/bin then ls -l and post results please? – emotality Jun 27 '16 at 9:48
  • @emotality Thanks, I've added it. Let me know if you need anything else. – Dambo Jun 27 '16 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) – user151019 Jun 27 '16 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 – user151019 Jun 27 '16 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 Jun 27 '16 at 12:46
15

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.

1

/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/ .

0

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

/usr/local/git/uninstall.sh

  • How does this uninstall /usr/bin/git? – nohillside Apr 29 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 Apr 29 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 Apr 29 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 Apr 29 at 15:49
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 "youremailaddress@example.com"

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

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

You must log in to answer this question.

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