After upgrading to macOS Ventura, I tried to run
git from Terminal but it kept giving me the following error:
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun.
Open Terminal, and run the following:
This will pop a dialogue box, Select "Install", and it will download and install the Command Line Tools package and fix the problem. (The popped Window may be behind other windows.)
You do not need Xcode, you can install only the Command Line Tools here, it is about 130 MB (600 MB as of Xcode v14.1).
If the above alone doesn't do it, then also run:
sudo xcode-select --reset
It's possible you may need to accept Xcode license too.
sudo xcodebuild -license accept