I upgraded macOS Monterey today, and when I used git in the terminal, an inexplicable error popped up:
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
The solution is to reinstall the xcode command line:
xcode-select --install
If it doesn’t solve the problem, execute the following command
sudo xcode-select -switch /