Git and GitHubgit 2.54 · GitHub · macOS, Linux or Windows
Dashboard
0%
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
26 small wins to finish your pathNext lesson →

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 and checking the version · from the Git and GitHub series · 2:05 to 3:07

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 git

Checking the version

One command says whether the install worked. It prints nothing about your files, so it is safe to run anywhere.

ExampleThe version this course was written against
git --version

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 the global user name and email · from the Git and GitHub series · 4:53 to 5:34

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.

bash
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.

ExampleSetting both values and reading them back
git config --global user.name "Reader"
git config --global user.email "reader@example.com"
git config --global user.name
git config --global user.email

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.

ini
[user]
	name = Reader
	email = reader@example.com

Every 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.

ExampleOne more global setting, then the whole file as Git reads it
git config --global init.defaultBranch main
git config --global --list

--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.

FlagFileApplies to
--systema file next to the Git installeveryone on the machine
--global~/.gitconfigevery repository of your user
--local, the default.git/config in the repositorythat 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.email is the first check.
Watch out. If you commit before setting a name and email, Git can fall back to your operating system user and machine name, and every commit you make carries that instead. GitHub cannot link such a commit to your profile, and the history keeps the wrong author forever unless you rewrite it. Set both values before your first commit.
Try it yourself
  • Run git config --global user.name with no value. It prints what is set, or nothing at all if you have not set it yet.
  • Open ~/.gitconfig in an editor, change the name by hand, save, and read it back with git config --global user.name.
  • Run git config --global core.editor nano to pick the editor Git opens when a command needs a message from you.

Little by little, you're building something great.