Just a quick reminder. I Recently deleted XCode for getting some free space disk (30Gb!), and suddenly I get the message above.
brew install git did not the trick. I use Git a lot, don't fuck me, Apple. All posts around the web say I must to install XCode. I don't want to do it. You only need the command line tools. So finally I found the command that saves my day:
sudo xcode-select -s /Library/Developer/CommandLineTools