A major macOS upgrade, and sometimes a minor one, removes or invalidates /Library/Developer/CommandLineTools. Every tool that shells out through xcrun then fails with 'xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: ...'. Because git, clang, make and many language toolchains on macOS are thin shims that call xcrun, the symptom is that git itself stops working, which looks far more alarming than it is.
The fix is 'xcode-select --install', which downloads the tools again. If a full Xcode is installed, 'sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer' points the active path at it instead, and 'xcode-select -p' prints the current setting.
In CI or in a scripted setup, check for the condition with 'xcode-select -p' and a test that the printed directory exists, before assuming a compiler is available. The interactive installer cannot be driven headlessly; runner images pre-install the tools, so a failure there usually means the image drifted rather than that the step is missing.