This error occurs when Git on macOS cannot find the Xcode Command Line Tools needed for certain operations. The xcodebuild utility is part of Apple's developer toolchain, and Git requires it for some advanced features. Installing or reinstalling the Command Line Tools resolves the issue.
This error message indicates that Git is trying to use `xcodebuild`, a tool from Apple's Xcode Command Line Tools, but the tools are not installed or not properly configured on your system. On macOS, Git relies on the Xcode Command Line Tools for certain operations, particularly those involving build processes or interacting with Apple's developer infrastructure. When these tools are missing, Git displays this error to inform you that it cannot complete the requested operation. The error most commonly appears in these scenarios: - After a fresh macOS installation before developer tools are set up - After a macOS major version upgrade that invalidated previous tool installations - When running Git operations that require compilation or build steps - When using Git with projects that have build hooks requiring Xcode tools
The most common fix is to install or reinstall the Xcode Command Line Tools:
xcode-select --installThis command opens a dialog prompting you to install the Command Line Tools. Click Install and wait for the download to complete (typically 5-15 minutes depending on your internet connection).
The package includes Git, compilers, and other essential development tools including xcodebuild.
After installation completes, verify everything is working:
# Check that xcodebuild is now available
xcode-select -p
# Expected output:
# /Library/Developer/CommandLineTools
# Verify Git works
git --version
# Check that xcodebuild is accessible
xcodebuild -versionIf xcodebuild -version shows version information, the tools are properly installed.
If you already have the tools installed but they're not working, reset the installation:
# Remove existing Command Line Tools
sudo rm -rf /Library/Developer/CommandLineTools
# Reset the developer directory selection
sudo xcode-select --reset
# Reinstall Command Line Tools
xcode-select --installThis ensures a clean installation without any corrupted files from a previous installation.
If you have Xcode installed, ensure the developer directory is pointing to the correct location:
# Check current developer directory
xcode-select -p
# If it shows an invalid path, switch to Command Line Tools
sudo xcode-select --switch /Library/Developer/CommandLineTools
# Or if you have full Xcode installed and want to use it
sudo xcode-select --switch /Applications/Xcode.app/Contents/DeveloperWhen to use each path:
- /Library/Developer/CommandLineTools - For standalone Command Line Tools installation
- /Applications/Xcode.app/Contents/Developer - When full Xcode is installed
If you have Xcode installed, you may need to accept the license agreement:
# Accept the license (requires admin password)
sudo xcodebuild -license accept
# Or review and accept interactively
sudo xcodebuild -licenseThe license must be accepted before xcodebuild and related tools can be used. This is a common issue after Xcode updates.
Some operations require the full Xcode installation, not just Command Line Tools:
1. Open the App Store on your Mac
2. Search for "Xcode"
3. Click Get to download and install (12+ GB download)
4. After installation, open Xcode once to complete setup
5. Accept the license agreement
Then set the developer directory:
sudo xcode-select --switch /Applications/Xcode.app/Contents/DeveloperNote: Full Xcode is only needed for iOS/macOS app development. For most Git operations, the Command Line Tools are sufficient.
If xcode-select --install fails, download the tools directly from Apple:
1. Go to https://developer.apple.com/download/more/
2. Sign in with your Apple ID (free account works)
3. Search for "Command Line Tools for Xcode"
4. Download the version matching your macOS version
5. Open the downloaded .dmg file and run the installer
After manual installation, verify with:
xcode-select -p
xcodebuild -version### Understanding xcodebuild vs Git
The xcodebuild utility is Apple's command-line tool for building Xcode projects. Git itself doesn't require xcodebuild for basic operations, but certain scenarios do:
- Git hooks that compile code before commits
- Git LFS operations involving binary files
- Submodules with build dependencies
- Git commands wrapped by scripts that invoke build tools
### Differences Between Command Line Tools and Full Xcode
| Feature | Command Line Tools | Full Xcode |
|---------|-------------------|------------|
| Size | ~1.5 GB | ~12+ GB |
| Git | Yes | Yes |
| xcodebuild | Yes (limited) | Yes (full) |
| iOS SDK | No | Yes |
| Simulator | No | Yes |
| Interface Builder | No | Yes |
For most developers, Command Line Tools provide everything needed for Git operations.
### After macOS Upgrades
Apple frequently invalidates Command Line Tools after major macOS upgrades. If you upgrade from one macOS version to another (e.g., Ventura to Sonoma), expect to reinstall:
# Check if reinstallation is needed
xcode-select -p
# If it shows an old path or errors, reinstall
# Full reinstallation process
sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install### Troubleshooting "Cannot Install" Errors
If you encounter errors during installation:
# Clear the software update catalog cache
sudo softwareupdate --clear-catalog
# Check available updates
softwareupdate --list
# If Command Line Tools appear in the list, install them
softwareupdate --install "Command Line Tools for Xcode-XX.X"### Corporate/MDM Managed Macs
On managed Macs, software installation may be restricted:
# Check for configuration profiles
sudo profiles showContact your IT department if xcode-select --install is blocked by policy.
### Multiple Xcode Versions
If you have multiple Xcode versions (common for iOS developers), ensure you're using the correct one:
# List available developer directories
ls -la /Applications | grep Xcode
# Switch to a specific version
sudo xcode-select --switch /Applications/Xcode-14.3.app/Contents/Developer
# Verify the switch
xcode-select -p### Environment Variables
Some scripts may require the DEVELOPER_DIR environment variable:
# Set DEVELOPER_DIR for the current session
export DEVELOPER_DIR=/Library/Developer/CommandLineTools
# Add to shell profile for persistence
echo 'export DEVELOPER_DIR=/Library/Developer/CommandLineTools' >> ~/.zshrcwarning: BOM detected in file, this may cause issues
UTF-8 Byte Order Mark (BOM) detected in file
fatal: Server does not support --shallow-exclude
Server does not support --shallow-exclude
warning: filtering out blobs larger than limit
Git partial clone filtering large blobs warning
fatal: Server does not support --shallow-since
Server does not support --shallow-since in Git
kex_exchange_identification: Connection closed by remote host
Connection closed by remote host when connecting to Git server