All commands

git config

Set the identity and behaviour Git uses when you commit.

What it does

git config reads and writes key/value pairs across three scopes: system (whole machine), global (your user), and local (this repository). Commits are stamped with the user.name and user.email from the most local scope that has them.

your-project/ · after git init
.git
├── HEAD
├── index
├── objects/
│ ├── info/
│ └── pack/
└── refs/
├── heads/
└── tags/

Config values cascade system → global → local

Watch it — press play

A narrated, step-by-step walkthrough that shows how to do it — not just theory. It adapts to the learner mode you picked in the top bar.

1 / 3

Step 1

Set your name

Before your first commit, Git needs an identity — the name and email written into every commit you make.

git config --global user.name "Your Name"
your-project/ · after git init
.git
├── HEAD
├── index
├── objects/
│ ├── info/
│ └── pack/
└── refs/
├── heads/
└── tags/

Identity lives in git config, applied from the narrowest scope

Under the hood

1

Three scopes, one merged result

Values cascade from wide → narrow. When Git needs a value, it checks local, then global, then system, and uses the first one found.

/etc/gitconfig      ← system   (--system)
~/.gitconfig        ← global    (--global)
.git/config         ← local     (this repo)
2

Written as INI text files

The configuration is just human-readable text. Setting a value appends a section and key to the appropriate file.

[user]
  name = Ada Lovelace
  email = ada@example.com
3

Commits read it at creation time

When you commit, Git bakes the resolved user.name and user.email directly into the commit object as author and committer lines. That's why old commits keep their identity even if you change config later.

Aliases the pros type

Memorize the git config concept, then let one of these shortcuts make it instant. Aliases are real git config keys — add one with:

git config --global alias.st # → git config --global
AliasWhy people use it
g cf

Shorthand for global config edits.

g cgl

Dump every configured alias and setting.

Command anatomy

git config <key> <value>
--global

Write to ~/.gitconfig (your user, all repos).

--local

Write to this repository only (default).

--list

Print the fully resolved config, aliases included.

alias.<name>

Create a shortcut: git config --global alias.co checkout.

When to reach for it

Just installed Git and must set user.name and user.email before your first commit.

You want to define aliases once that work in every repository.

You have two identities (work vs personal) and pin one per repo with --local.

Pro tip

See every alias you've ever defined (including the ones the site suggests) with `git config --global --get-regexp ^alias`.

Go deeper with