Unable to run git command in terminal after upgrading Mac OS


Problem: command line tools not working after macOS upgraded from 4.13 OS X 10.11 El Capitan to 4.14 macOS 10.12 Sierra

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

Solution: reinstall command line tools

$ xcode-select --install

Found this solution from stack overflow:

Open Terminal, and run the following:

xcode-select --install

This will bring up a prompt to install the necessary command line tools. This will download and install xcode developer tools and fix the problem. The problem is that one needs to explicitly agree to the license agreement.