Skip to the workspace
Pebellslearn by building
Learn the Basics  ›  Lesson

Installing Git and Telling It Who You Are

git config 12 minAfter installing Git you set your name and email, and Git reads settings from local, global and system levels, with the most specific level winning.

git github / Installing Git and Telling It Who You Are

Explore each scene at your own pace.

01 · The rule

The rule

Installing Git and Telling It Who You Are

Before Asha records her first snapshot, Git needs two things: to exist on her computer, and to know whose name to write on every commit. Skip the second step and her commits end up signed by a guessed name like asha@Ashas-MacBook.local.

The rule

Install once, then set your name and email; the nearest setting wins.

Installing. Git is free and runs everywhere:

# macOS: installs Apple's command-line tools, which include Git
xcode-select --install
# or, with Homebrew
brew install git

# Debian or Ubuntu Linux
sudo apt install git

# Windows: download and run the Git for Windows installer,
# which also gives you Git Bash

Check it worked:

git --version

It should print a line such as git version 2.45.1. The exact number does not matter for this course, as long as it is reasonably recent. If the terminal says the command is not found, the install did not finish or the terminal needs reopening.

Configuring. Every commit is stamped with a name and email, so set them once:

git config --global user.name "Asha Rao"
git config --global user.email "asha@example.com"
git config --global init.defaultBranch main

The last line makes new repositories start on a branch called main.

Git reads settings from three levels:

  • --system: every user on this computer.
  • --global: you, in every repository. Stored in a file in your home folder, ~/.gitconfig.
  • --local: one repository only. Stored in that repository's .git/config. This is the default when you run git config inside a repository without a level flag.

When the same key is set at more than one level, the most specific one wins: local beats global, and global beats system.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.