Is git already installed when buying a new Macbook?

Greetings,
due to the current situation (Corona-Virus) I had to download Xcode, MS Visual Studio and Visual StudioCode on my personal MacBook Pro (2017; no Touch Bar).

These applications were all asking for git (git-scm) and I have accepted. After some regrets I have decided to delete all applications again.

I was able to delete Xcode, MS VS and VS Code but there was no program with the name git“, but hundreds of files with a big red „h“ on them, that I have never seen before.

I used the function for a secured system restart and at the end I was reinstalling MacOS BigSur. Every time I logged in my entire display was black and my cursor in a neon blue
I installed a new MacOS again and now everything seems to be fine (at least no black screen).

I used some codes, I got from google, on my terminal (sudo rm -rf /usr/bin/git/), I am afraid that it has done more damage than it was helpful.

Any idea how I can reverse the last 24 hours?


Summary:


Is Git already installed when I buy a new MacBook?
If not, how can I delete all unnecessary files?
Has „sudo rm -rf /usr/bin/git/„ changed anything?

My terminal said that I was having Apple Git 128. After deleting XCodes there seems to be no git

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

Sorry for all the questions, but I am totally unskilled when it is about using git.


Kind Regards,
git is not installed on macOS by default. The binary at /usr/bin/git is a shim that redirects any calls to that command line tool to the version in the current version of Xcode or the Command Line Tools downloadable package. This is so the tool is updated as Xcode updates, among other benefits.

To rectify your situation, either install Xcode, or download the Command Line Tools package. Once you've done that, you can set the active installation of the tools using:
Code Block
% xcode-select -s /Path/To/Xcode/

If you're using the command line tools package, that becomes:
Code Block
% xcode-select -s /Library/Developer/CommandLineTools

Hey @edford,
thanks for the response. As you have suggested, I have reinstalled Xcode and then I used the first command (% xcode-select -s /Path/To/Xcode/).

The response from my terminal was: -bash: fg: %: no such job

I also tried the second code: -bash: fg: %: no such job

I don’t think that this was the the intended outcome, right?

Regards.
Quick update: I was going to my user account (Macintosh HD) > library > Developer.
There were two folders "Command Line Tools" and "Private Frameworks".
I have deleted the entire "Command Line Tools" folder.


Now when I use the command

Code Block
git --version


The terminal is asking me for the installation of the C L tools.

That should now be the status before I had the entire mess.
Command Line Tools is also not installed my default, so there shouldn't be a problem for my MacBook?

Thanks in advance.

Kind Regards.

Given that this is from over a year ago, I trust you have already resolved this.

But, for future reference, macOS does not come with git by default. You have to install Xcode and the Xcode Command Line Tools. You can download and install Xcode from the Apple Developer site, but it is easier and more reliable (as a normal user, one that does not have to run pre-release versions) to install it from the App Store.

You can install the Command Line tools from the (you got it) command line (Terminal), with

xcode-select --install

There are other ways to install just git without Xcode. The most popular being using the open-source package manager HomeBrew (brew)

Install brew following the instructions on their website https://brew.sh/

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

(if you know what you're doing, this can be a little daunting - you are essentially downloading a shell script off the internet and running it as your user!)

Once installed, you can install git with

brew install git

Is git already installed when buying a new Macbook?
 
 
Q