Installing Git
Installing Git puts the git command in your terminal, and two settings put your name and email on every commit you make with it.
Last updated: 12 Oct, 2026 · git 2.54
Git is one program, the same on every operating system, and the download is different on each. After the download there are two settings to make once per machine, because every commit stores who wrote it.
Downloading Git for your operating system
Pick your system below. Every command is run in a terminal. The installers for all three live on git-scm.com/downloads, and the Windows installer also brings Git Bash, a terminal that understands the commands in this course.
# the command line tools, which include git
xcode-select --install
# or, with Homebrew, a newer build
brew install gitChecking the version
One command says whether the install worked. It prints nothing about your files, so it is safe to run anywhere.
git --versiongit version 2.54.0 (Apple Git-157)
The number is what matters: 2.54 here. Apple and most Linux distributions ship their own build, so the string can carry a vendor name after the number. Anything from 2.23 up has the git switch and git restore commands this course uses. If the terminal answers command not found, the install did not finish, or the terminal was open before it did and needs restarting.
Setting your name and email
Git stamps every commit with a name and an email address. It has no login, so it takes them from its own configuration. Set them once and every repository on the machine uses them.
Syntax: git config --global <key> <value> writes a setting for your whole machine. The same command with the key alone reads it back.
git config --global user.name "Your Name"
git config --global user.email "you@example.com"Use the email address of your GitHub account. GitHub matches commits to your profile by that address, as its commit email address page describes.
git config --global user.name "Reader"
git config --global user.email "reader@example.com"
git config --global user.name
git config --global user.emailReader reader@example.com
The file those commands write
--global is a plain text file in your home folder, ~/.gitconfig. The two commands above leave it looking like this, and you can open it in any editor.
[user]
name = Reader
email = reader@example.comEvery captured output in this course was run with that file in place, which is why the commits on the following pages are authored by Reader. Yours will carry your own name.
Choosing the default branch name
A new repository starts with one branch. Git's own default name for it is master, and GitHub names it main. The init.defaultBranch setting, listed on the git config page, makes your machine agree with GitHub.
git config --global init.defaultBranch main
git config --global --listuser.name=Reader user.email=reader@example.com init.defaultbranch=main
--list prints every setting in that file as key=value. Git lowercases the key when it reads it, so init.defaultBranch comes back as init.defaultbranch. The value is what counts.
The three places a setting can live
The same key can be set at three levels. The narrowest one wins, so a repository can override your machine.
| Flag | File | Applies to |
|---|---|---|
--system | a file next to the Git install | everyone on the machine |
--global | ~/.gitconfig | every repository of your user |
--local, the default | .git/config in the repository | that one repository |
Inside a project with a work address, git config user.email "you@company.com" without --global sets it for that project alone.
Where you use these settings
- A new machine. Install Git, set the two identity values, set the default branch name, and you are ready to make a repository.
- A work laptop with two accounts. Keep your personal address global and set the work address locally in the repositories that need it.
- A commit that shows the wrong author. Reading
git config --global user.emailis the first check.
Related
- Previous: Git and GitHub
- Next: Your first repository
- Reference: First-time Git setup in the Git book
- Run
git config --global user.namewith no value. It prints what is set, or nothing at all if you have not set it yet. - Open
~/.gitconfigin an editor, change the name by hand, save, and read it back withgit config --global user.name. - Run
git config --global core.editor nanoto pick the editor Git opens when a command needs a message from you.
Little by little, you're building something great.