23

I have updated Xcode version to 7.3.1.when I use 'git status',I find an error! as follow:

$git status
sh: line 1:  1601 Segmentation fault: 11  /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -sdk / -find git 2> /dev/null
git: error: unable to find utility "git", not a developer tool or in PATH

Thank you advanced!

Levon
  • 138,105
  • 33
  • 200
  • 191
wenyc
  • 263
  • 1
  • 3
  • 8

6 Answers6

97

This happened to me also with upgrading to High Sierra and XCode to 9. This sequence has fixed it.

xcode-select --install
sudo xcode-select -s /Library/Developer/CommandLineTools

Found this answer on https://davidwalsh.name/fix-git-high-sierra-upgrade (article and comments.)

Gedas Kutka
  • 1,306
  • 10
  • 9
  • Thanks this is amazing! :) – DK5 Nov 27 '18 at 09:47
  • This is the best answer because it requires no reboot or restart :) Through many cycles of sleep/wake terminal can lose reference to command line tools. If you already have xcode-select installed (as many do) just running the second line fixes this. – Prasith Govin Dec 18 '18 at 12:54
57

I had this same problem -- I exited my bash session (closed the terminal) and started a new one and it fixed it.

RhinoDavid
  • 796
  • 5
  • 9
6

The best solution will be to download and install it - even that you assume it is already installed: https://git-scm.com/download/mac

yorammi
  • 6,272
  • 1
  • 28
  • 34
  • 1
    Thank you very much for your help! I have solved this problem in the way that you provided! – wenyc Jun 06 '16 at 06:03
  • 3
    If you have Homebrew installed, you can install Git via the `brew install git` command. See here: https://git-scm.com/book/en/v1/Getting-Started-Installing-Git – Adil Hussain Jan 03 '17 at 10:39
  • 1
    This is a workaround that doesn't fix the underlying problem -- that xcode for some reason fails to launch developer tools. It should not be the accepted answer. You will just run into the same problem with other developer tools. – Jakob Egger Sep 25 '19 at 10:01
  • well, at the time of the question (more than 3 years ago), it solved the problem for him so he accepted the answer. – yorammi Oct 02 '19 at 04:06
2

I had the same issue after upgrading to Big Sur. I fixed this issue by running the following command:

sudo xcode-select -switch /Library/Developer/CommandLineTools

P.S. I did not need to run this command: xcode-select --install

K M Rakibul Islam
  • 33,760
  • 12
  • 89
  • 110
0

For me, I had to uninstall and reinstall all my brew applications, as documented here.

i.e.

brew list -1 > brew.txt # list out all installed packages
brew list -1 | xargs brew rm --force # remove all installed packages
brew install $(cat brew.txt | tr '\n' ' ') # install all previously installed packages
Nick Grealy
  • 24,216
  • 9
  • 104
  • 119
0

None of the above solutions fixed the issue for me, I had to actually just restart my computer which fixed it. This was a weird bug.

Jose
  • 1,959
  • 20
  • 21