Git
The version control system everything else on this page is a front end for.
What it does
Git tracks content as a directed graph of commits, each a full snapshot addressed by hash. Branching is cheap, history is rewritable before it is shared, and every clone is a complete repository.
Why install it from Homebrew
macOS ships a Git that comes from the Xcode Command Line Tools — usually a year or more behind, and it disappears or reverts across Xcode updates. The Homebrew build is current and stays where you put it.
git --version
which -a git # /opt/homebrew/bin/git should winTwo identities on one machine
Working under more than one GitHub account is where Git quietly does the wrong thing. Two settings fix it:
git config user.nameanduser.emailset per repository, so commits are attributed correctly without a global default fighting them.- An SSH host alias in
~/.ssh/configper account, with the remote written against the alias (git@github-work:org/repo.git) so the right key is offered.
Rewriting such a remote back to git@github.com: silently selects the default key and the push fails, or worse, succeeds as the wrong user.
Alternative to
| Alternative | Type | Trade-off |
|---|---|---|
Jujutsu (jj) | Open source | Git-compatible storage with a much better model for rewriting history |
| Mercurial | Open source | Simpler and more consistent; still used at scale inside a few large companies |
| Fossil | Open source | Version control, bug tracker and wiki in one file |
| Perforce or Subversion | Paid / Open source | Centralised, and still standard in games and some enterprises |
Install
brew install git