Installing and configuring Git

Beginner · 7 min

Install Git, set the name, email, editor and default branch it stamps on your work, and learn the three config levels and how to see which one wins.

Before thisWhy version control exists

Alex The Analyst · 7 min

Installing and configuring Git

The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.

Taught by Alex The AnalystReport a problem with this video
Not started
Set this lesson's status

What you'll learn

  • Git stamps every commit with the name and email from your config, so set both once with git config --global.
  • Config has three levels: system, global (your user), and local (one repository). The most specific level wins.
  • git config --show-origin tells you which file a setting came from, which is the fastest way to debug a surprising value.
  • Setting init.defaultBranch to main makes new repositories start on main instead of the legacy master.
  • The email in your config is public once you push commits, so choose one you are happy to expose.

Install first, check second

Git is a command-line program, so installing it means getting a git command onto your path. The usual ways:

  • Windows: the installer from git-scm.com. It also installs Git Bash, a terminal where the commands in this roadmap behave as written.
  • macOS: running git in Terminal offers to install Apple’s command line tools, or you can use Homebrew with brew install git.
  • Linux: your package manager, for example sudo apt install git or sudo dnf install git.

I could not run any of those installers while writing this lesson, so check the current instructions on the Git website if one fails. What I did run is the check that tells you it worked:

$ git --version
git version 2.54.0 (Apple Git-157)

Your number will differ. Any recent version handles everything in this roadmap. The parenthesis on my output is Apple’s build of Git, and you won’t see it on other systems. A few commands here, such as git switch and git restore, need version 2.23 or newer, so if git --version shows something older than that, update.

Why Git needs to know who you are

Every commit records an author name and an email. Git has no login screen, so it reads these from config. If it finds none, behaviour depends on the machine. On my Mac, Git guessed from my username and hostname, committed anyway, and printed a warning:

Committer: <my username> <my username@my-laptop.local>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.

I only tested the Mac case. On other systems Git may stop with an “Author identity unknown” error instead. Either way, set it yourself so the history carries a real name:

$ git config --global user.name "Ada Example"
$ git config --global user.email "ada@example.com"
$ git config --global init.defaultBranch main
$ git config --global core.editor "nano"

init.defaultBranch decides what the first branch of a new repository is called. Without it, Git 2.54 prints a hint on every git init saying that master is the current default and that the default will change to main in Git 3.0. Setting it now silences the hint and makes your repositories match what GitHub creates. core.editor is the program Git opens when it needs a longer message from you. Pick one you can exit; if you are not sure, nano shows its keys at the bottom of the screen.

Your email will be readable by anyone who sees your commits once you push them somewhere public. GitHub offers a private noreply address for this, which a later lesson covers.

Three levels of config

Git reads settings from up to three files, and later ones override earlier ones.

Level Flag Applies to Lives in
system --system every user on the machine a file under Git’s install directory
global --global you, in every repository ~/.gitconfig
local --local (the default when you’re in a repo) one repository .git/config inside it

After the four commands above, my global file looked like this. It is plain text, so you can edit it by hand:

[user]
	name = Ada Example
	email = ada@example.com
[init]
	defaultBranch = main
[core]
	editor = nano

To list everything Git currently sees:

$ git config --global --list
user.name=Ada Example
user.email=ada@example.com
init.defaultbranch=main
core.editor=nano

Key names are case-insensitive, which is why defaultBranch is shown in lowercase there. Newer Git also accepts git config list, git config get user.name and git config set user.name "..." as spellings of the same operations. I ran those forms and they behave the same as the older flags.

Which level wins

The reason for levels is that you often want one identity at work and another for personal projects. Set the personal one globally and override it inside the work repository:

$ git config user.email "ada@work.example"
$ git config --show-origin --get-all user.email
file:.../gitconfig	ada@example.com
file:.git/config	ada@work.example

Both values exist. The last one listed, the local one, is what a commit uses. --show-origin prints the file each value came from, and it is the first thing to reach for whenever Git behaves as if it has a setting you don’t remember choosing. Remove a setting with git config --unset, adding --global if it lives in the global file.

What the video covers

Alex The Analyst’s “Installing and Setting up Git and GitHub” is about seven minutes and was published in September 2025. Its description links the Git and GitHub downloads and promotes the creator’s own course. From the title it walks through installing Git and setting up a GitHub account, so it covers the install half of this lesson and probably only touches configuration. It has no chapter list and I couldn’t read a transcript. The channel is English-language, judged from the title and description only. Expect it to be aimed at Windows users and to bring in GitHub early, which this roadmap leaves for later. Richard Hildred’s short video on setting user.name and user.email is linked for the config half.

Where this fits

Git knows who you are. Next, the idea that makes everything else in Git make sense: the three areas of Git.

Check yourself

  1. 01Where does git config --global write its settings?

    To a file in your home directory, normally ~/.gitconfig or ~/.config/git/config, and it applies to every repository you own.

  2. 02A repository's .git/config sets user.email to a work address and your global config has a personal one. Which does a commit there use?

    The work address. The local level is more specific than the global level, so it wins.

  3. 03How do you find out which file a setting is coming from?

    Run git config --show-origin followed by the key, for example git config --show-origin user.email.

Go deeper

Notes

Private to you

Esc
↑↓ navigate↵ open? shortcuts

Keyboard shortcuts

Press Esc to close

Anywhere

⌘K
Search and commands
/
Search
?
This sheet
Esc
Close

Reading a lesson

J
Next lesson
K
Previous lesson
B
Bookmark