9

I installed the GitHub UI for OS X from here: https://central.github.com/mac/latest. As part of the installation I get an option to "Install Command Line Tools". On doing so it places the relevant assets under /usr/local/bin. I assumed it would register git in the PATH variable as well so that I could run it from the terminal if needed. However it doesn't work from the terminal, instead if I run 'git' in terminal, I get prompted to install XCode.

Am I assuming something incorrectly here? Also tried installing git from here: http://git-scm.com/download/mac. After the installer completed successfully, I still can't seem to be able to use git from the terminal.

UPDATE: my PATH variable has the following:

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin

Cranialsurge
  • 6,104
  • 7
  • 40
  • 39
  • First, you need to restart bash (e.g. by opening a new terminal) after installing something that modifies the default values of environment variables. Second, what does `echo $PATH` say? – Robin Green Nov 10 '13 at 08:14
  • /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin – Cranialsurge Nov 11 '13 at 09:29
  • Whenever I try and invoke git from the terminal I get the following message with a prompt: xcode-select: note: no developer tools were found at '/Applications/Xcode.app', requesting install. Choose an option in the dialog to download the command line developer tools. – Cranialsurge Nov 11 '13 at 09:31
  • Any chance you can try and put `/usr/local/git/bin` first in the `PATH`? (just in one shell session, to see how XCode and git react then) – VonC Nov 11 '13 at 10:32

3 Answers3

12

As mentioned in "git on Mac: replace Apple XCode CLI git with symbolic link to latest git install?", it dpeends on the order of the folders in the PATH environment variable.

  • XCode CLI installer puts a copy of git in /usr/bin
  • Reinstalling the latest git from git-scm.com put git in /usr/local/git/bin/git

If git command line is installed in /usr/local/git/bin, make sure to put that in first:

PATH=/usr/local/git/bin:$PATH
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
2

Just download these tools running command in terminal:

xcode-select --install

If it doesn't help you try to download them manually form apple developer site: https://developer.apple.com/downloads/index.action?=command%20line%20tools#

It helped me.

averem
  • 376
  • 5
  • 7
  • i agree, non of command line solutions worked for me, i installed manually and worked https://developer.apple.com/download/all/?q=command%20line%20tools – greenridinghood Sep 12 '22 at 21:17
0

This command worked for me

sudo xcode-select -switch /Library/Developer/CommandLineTools
Shrikant
  • 579
  • 1
  • 5
  • 21