After upgrading macOS, git often does not run correctly. I recently updated to Monterey and hit the same error again. The message was identical to what I saw when I upgraded to Catalina. (It seems to happen almost every upgrade.)

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

You can reproduce the error by running development commands such as git or gcc in Terminal.

$ git
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

The fix is simple. Install the command line tools with xcode-select --install.

$ xcode-select --install

Depending on your environment, installation time varies. In my case, it took about 10 minutes.