→ About This Mac → Overview → macOS High Sierra
Version 10.13.6
- Website: https://www.apple.com/macos/high-sierra/
- Mac App Store Preview: https://itunes.apple.com/app/macos-high-sierra/id1246284741
- Mac App Store: macappstore://itunes.apple.com/app/id1246284741
Xcode → About Xcode → Xcode
Version 10.0 (10A255)
- Website: https://developer.apple.com/xcode/
- Mac App Store Preview: https://itunes.apple.com/app/id497799835
- Mac App Store: macappstore://itunes.apple.com/app/id497799835
- Use the Mac App Store app to install Xcode.
- After installing Xcode, run it at least once to install additional components, which include Git.
- Note: Apple's bundled version of Git is typically a few versions behind the current version of Git.
pkgutil --verbose --pkg-info=com.apple.pkg.CLTools_Executables
version: 10.0.0.0.1.1535735448
- Install Command Line Tools for Xcode, which includes Git:
xcode-select --install
- Use the Mac App Store app to update Command Line Tools for Xcode.
- Note: Apple's bundled version of Git is typically a few versions behind the current version of Git.
brew --version
Homebrew 1.7.5
Homebrew/homebrew-core (git revision 4f53; last commit 2018-09-18)
- Website: https://brew.sh/
- Install Homebrew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- Note: Installing Homebrew also installs Command Line Tools for Xcode.
- Use the Mac App Store app to update Command Line Tools for Xcode.
- Update Homebrew itself:
brew update
- Upgrade Homebrew apps:
brew upgrade
- Install Git:
brew install git
- After installing Git, quit the Terminal application before using it.
- Note: The Homebrew Git package will typically be more up-to-date than the version of Git that is bundled with Command Line Tools for Xcode.
Command | which git |
git --version |
xcrun --find git |
xcrun --run git --version |
---|---|---|---|---|
XcodeNote 1 | /usr/bin/git |
git version 2.17.1 (Apple Git-112) |
/Applications/Xcode.app/Contents/Developer/usr/bin/git |
git version 2.17.1 (Apple Git-112) |
Command Line ToolsNote 1 | /usr/bin/git |
git version 2.17.1 (Apple Git-112) |
/Library/Developer/CommandLineTools/usr/bin/git |
git version 2.17.1 (Apple Git-112) |
HomebrewNote 2 | /usr/local/bin/git |
git version 2.19.0 |
/Library/Developer/CommandLineTools/usr/bin/git |
git version 2.17.1 (Apple Git-112) |
Git Installer |
Note 1: For Xcode and Command Line Tools for Xcode,
/usr/bin/git
is a stub that runs the actual ./usr/bin/git
program
contained within the Xcode application package or within the Command Line Tools for Xcode,
according to the currently-active Xcode developer directory:
Command | xcode-select --print-path |
---|---|
Xcode | /Applications/Xcode.app/Contents/Developer |
Command Line Tools | /Library/Developer/CommandLineTools |
HomebrewNote 2 | /Library/Developer/CommandLineTools |
Note 2: Homebrew also installs Command Line Tools for Xcode,
which itself installs an older version of Git that is invoked from /usr/bin/git
.
However, Homebrew installs its version of Git to /usr/local/bin/git
,
which, by default, occurs earlier in the search path;
therefore the git
command by itself without a path will invoke Homebrew's Git.
echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
The file paths mentioned below are generalizations based on my own observations of clean installs on a freshly installed operationg system. For more specific details, refer to the official documentation: https://git-scm.com/docs/git-config.
Note: A more-specific setting will override a more-general setting. Specifically:
- A
--local
setting will override a--global
,--system
, "core" and/or "program default" setting. - A
--global
setting will override a--system
, "core" and/or "program default" setting, but not a--local
setting. - A
--system
setting will override a "core" and/or "program default" setting, but not a--local
or--global
setting. - A "core" setting will override a "program default" setting, but not a
--local
,--global
or--system
setting.
In the absence of a more-specific configuration setting in one of the locations below, Git will use it's own built-in program defaults.
There is currently no command to display those built-in program default settings,
because the git config
command only operates on the settings specified in the files below,
and has no knowledge of Git's built-in settings.
Examine the Git source code (https://github.com/git/git) to determine what built-in settings the program uses by default.
A setting applies to all repositories for all users, and overrides a default program setting, unless overridden by a more-specific setting below.
Command | git config --list --show-origin |
xcrun --run git config --list --show-origin |
---|---|---|
Xcode | /Applications/Xcode.app/Contents/Developer/usr/share/git-core/gitconfig |
/Applications/Xcode.app/Contents/Developer/usr/share/git-core/gitconfig |
Command Line Tools | /Library/Developer/CommandLineTools/usr/share/git-core/gitconfig |
/Library/Developer/CommandLineTools/usr/share/git-core/gitconfig |
Homebrew | N/A | /Library/Developer/CommandLineTools/usr/share/git-core/gitconfig |
Git Installer |
Note: There isn't actually a command to display or change these "core" settings explicitly;
but the git config
command without the --system
, --global
or --local
options will
--list
and --show-origin
of any such settings that are not overridden by more specific
settings below. In this way, this command might reveal the location of such a "core" settings file.
A setting applies to all repositories for all users, and overrides a more-general setting above, unless overridden by a more-specific setting below.
Command | git config --system --list --show-origin |
xcrun --run git config --system --list --show-origin |
---|---|---|
Xcode | /etc/gitconfig |
/etc/gitconfig |
Command Line Tools | /etc/gitconfig |
/etc/gitconfig |
Homebrew | /usr/local/etc/gitconfig |
/etc/gitconfig |
Git Installer |
A setting applies to all repositories for the current user only, and overrides a more-general setting above, unless overridden by a more-specific setting below.
Command | git config --global --list --show-origin |
xcrun --run git config --global --list --show-origin |
---|---|---|
Xcode | ~/.gitconfig |
~/.gitconfig |
Command Line Tools | ~/.gitconfig |
~/.gitconfig |
Homebrew | ~/.gitconfig |
~/.gitconfig |
Git Installer |
A setting applies only to the current repository for all users, and overrides a more-general setting above.
Command | git config --local --list --show-origin |
xcrun --run git config --local --list --show-origin |
---|---|---|
Xcode | /path/to/repository/.git/config |
/path/to/repository/.git/config |
Command Line Tools | /path/to/repository/.git/config |
/path/to/repository/.git/config |
Homebrew | /path/to/repository/.git/config |
/path/to/repository/.git/config |
Git Installer |
Installing Git: https://git-scm.com/book/en/Getting-Started-Installing-Git
Configuration Documentation: https://git-scm.com/docs/git-config