7

I am very new to macOS, knowing Ubuntu a little bit, and am wondering whether git is pre-installed on macOS or not. Typing

which -a git

results in

git is /usr/bin/git

But when I init a test-repo and checkout a myBranch, the command

git branch

results in a empty line. So is there anything I do forget? I installed Homebrew before checking for git, so maybe this causes some interdependencies?

1 Answer 1

10

macOS does come with a binary at /usr/bin/git, however by default it's a wrapper around the command line tools installer. Running the command will print the following and return immediately.

note: install requested for command line developer tools

A prompt will ask the user to install the command line tools, with a button that downloads and installs the toolset.

Once installed, /usr/bin/git will be a proper version of Git compiled by Apple (noted by the ‘Apple Git’).

$ /usr/bin/git --version
git version 2.24.3 (Apple Git-128)

If Git is installed using Homebrew, it will be at /usr/local/bin/git by default on Intel, at /opt/homebrew/bin/git on ARM.

2
  • 1
    Thanks for the quick answer! Do you have any suggestions which git to use? I tried to add the current git-branch to my terminal prompt like described here, but this resulted in some errors, where always $(parse_git_bash) was written behind the standard prompt.
    – krahlos
    Commented Oct 31, 2017 at 13:10
  • @marco05772 The homebrew git is a slightly newer version 2.31.1 versus 2.24.3. So use the one you're most comfortable with.
    – jksoegaard
    Commented Apr 8, 2021 at 8:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .