Trouble setting up Git on Macbook

I am having some trouble setting up Git on my Macbook. When I open the Terminal and type in git, I get the following message:

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

After a quick Google search, I found that many people had success by writing:

xcode-select --install

I get a message that asks me if I would like to install the Command Line Developer Tools, so I select install and agree to the terms. However, I then get a message that says:

“Can’t install the software because it is not currently available from the Software Update server.”

So after another Google search, I tried writing:

sudo xcode-select --reset

I enter my password, and then select enter, and nothing visibly changes. So I try writing git, and then xcode-select --install again, and the same thing keeps happening over and over in a circle.

I don’t know what to do!

This error can sometimes show up when the tools are already installed.

Try running softwareupdate -l and see if the command line tools show up there.