Question: I just upgraded from Yosemite to El Capitan (and replicated the problem upgrading from El Capitan to Sierra), and when I try to type for example `git status` inside a terminal, I get the following error:

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

```

I don't have Xcode installed, never did. 
Anyone have a solution?

Answer: 
For the most recent version Mojave version 10.14.1, I use 

solved by downloaded from <https://developer.apple.com/download/more/> " login by apple id, and download 

> 
> Command line tool newest stable version.dmg
> 
> 
> 

That makes everything work

the old answer 

```
xcode-select --install

```

doesn't work for me.
Even if you do xcode-select --install it was not fixing that for me as it showed some network error. The problem was that it could not connect to the app store. I did the following to fix it.

1. Open keystore
2. Go to system root and select certificates.
3. Open digicert high assurance EV.
4. Expand the trust section, mark it as never trust.
5. Restart system now repeat step 1, 2, 3. and mark the trust policy as
back to use system defaults.

Your app store should work now and you should be able to run xcode-select --install