OK, I found the problem: the message was coming from the remote git server, not the client side. I ran sudo xcodebuild -license
on the server side (where the repo is located and the git server is running) and the problem went away. Sigh.
Your PATH variable got contaminated by some irregular file content: either your git file in /etc/paths.d/, /etc/profile or ~/.MacOSX/environment.plist or all three are corrupted.
Use shiftcmdG in Finder to jump to each of the folders and check the content of them.
/etc/paths.d/ should contain a file git with the content /usr/local/git/bin
. If you have installed other apps like X11 there may be additional files in paths.d - all containing paths.
The file profile in /etc/ should contain at least
# System-wide .profile for sh(1)
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
fi
if [ "${BASH-no}" != "no" ]; then
[ -r /etc/bashrc ] && . /etc/bashrc
fi
The file environment.plist should look like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PATH</key>
<string>/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin</string>
</dict>
</plist>
The PATH string may contain other paths as well. The file may contain other keys - depending on other installs you have made previously.
If you have found irregular content in one of the files simply replace it with the content shown above. You have to be an admin to modify the first two files because they are root:wheel realm. If you use TextEdit or another text editor to modify them, be sure to save them as plain text and without file extension (i.e. .txt). You can ignore a missing ~/.MacOSX/environment.plist because it isn't supported in your environment (system version) anymore, besides you use some hacks.
Best Answer
Solution
Open Terminal, and run the following:
This will download and install the Command Line Tools package and fix the problem.
You do not need Xcode, you can install only the Command Line Tools here, it is about 130Mb.
If the above alone doesn't do it, then also run:
Further reading
The problem is that one needs to explicitly agree to the license agreement. As a follow on step, you may need to reset the path to Xcode if you have several versions or want the command line tools to run without Xcode.
I found the solution in this question, Command Line Tools not working.
You may get an error message: "Can't install the software because it is not currently available from the Software Update server". In this case
xcode-select --reset
works as pointed by akozin.