2 min read

Install Git

Install Git on macOS, Linux, and Windows. Configure your name and email so commits are attributed correctly. Verify the install in one command.

Install Git

Git is the version-control tool every other engineering tool assumes you have. Without it you can't clone a repo, can't install most dev libraries from source, and can't contribute to open source. This post is the prerequisite for almost every other install post on this blog.

macOS

The simplest path is via Homebrew. macOS also ships with a git shim that prompts you to install Xcode Command Line Tools — that works too, but the brew version updates faster.

# install git via homebrew

brew install git

If you don't have Homebrew yet, see Install Homebrew.

Linux

Use the system package manager.

# install git on debian / ubuntu

sudo apt update && sudo apt install git
# install git on fedora / rhel

sudo dnf install git
# install git on arch

sudo pacman -S git

Windows

Download Git for Windows from git-scm.com/download/win. The installer bundles Git Bash, which is what you want — Windows command prompt and Git don't get along well, and Git Bash gives you a Unix-style shell.

Alternative: install via winget.

# install git via winget on windows

winget install --id Git.Git -e --source winget

Configure your identity

Git refuses to commit until it knows who you are. Set your name and email globally — same email you use on GitHub.

# set your name globally

git config --global user.name "Your Name"
# set your email globally

git config --global user.email "you@example.com"

I also turn on a few defaults that save grief later:

# default branch name on new repos

git config --global init.defaultBranch main
# rebase by default on pull, no merge commits

git config --global pull.rebase true

Verify

# print git version

git --version

You should see git version 2.40+ or higher. Older versions miss features like sparse-checkout and partial-clone that some tutorials assume.

Common gotchas

  • HTTPS vs SSH for GitHub: HTTPS asks for a token every push; SSH uses a key. For any repo you'll push to more than once, set up SSH keys. ssh-keygen -t ed25519 -C "you@example.com", then add the public key to GitHub.
  • Line endings on Windows: Git on Windows can rewrite line endings (CRLF ↔ LF) on checkout. For cross-platform projects set git config --global core.autocrlf input.
  • First push fails with "refusing to merge unrelated histories": usually means you initialized locally and on GitHub. Use git pull --allow-unrelated-histories origin main once, then continue normally.

With Git installed and configured, you're ready to clone any repo and use any tool that builds from source.

Rate this article

How helpful did you find this?

Newsletter

Get new articles in your inbox

AI engineering, LLM systems, and software architecture — no filler.

No spam. Unsubscribe any time.

Discussion

Comments

Leave a note about the article, architecture choices, or what you would build next.

Comments are stored in Supabase and fetched per post slug.

Loading comments...