Skip to main content

Sign in

Save your progress and access it from any device.

Or with email

Don't have an account?

Privacy policy

Git config: configure Git your way

Before you start using Git, you need to configure it. Name, email, editor, aliases: this page explains how to customize Git so it works the way you want.

The 3 configuration levels

Git manages configuration at three levels. The most specific level always takes priority.

Level 1

--system

Applies to all users on the machine. Rarely modified manually.

/etc/gitconfig
Level 2

--global

Applies to all repos on your account. This is the most commonly used level for personal config.

~/.gitconfig
Level 3

--local

Applies only to the current repo. Useful for having a different work email per project.

.git/config

Git config in practice

Essential setup and creating aliases to save time.

Basic configuration

Aliases and overview

Essential configuration settings

user.name

Your name, displayed in every commit. Required to commit.

git config --global user.name "Your Name"
user.email

Your email, associated with every commit. Use the one from your GitHub account.

git config --global user.email "your@email.com"
core.editor

The editor Git opens (for commit messages, interactive rebase, etc.).

git config --global core.editor "code --wait"
init.defaultBranch

The default branch name when running git init. The modern convention is "main".

git config --global init.defaultBranch main
pull.rebase

Enables automatic rebase during git pull, for a linear history.

git config --global pull.rebase true
alias.*

Create shortcuts for long commands. Essential for working faster.

git config --global alias.st status

Configuration tips

1

Set up your name and email first

This is required to commit. Do it once with --global and it's set for all your projects.

2

Use --local for work projects

If you have a personal email set globally, use --local in your work projects to associate your professional email.

3

Create aliases from the start

Aliases like git st, git co and git lg will save you time every day.

4

Back up your .gitconfig

The ~/.gitconfig file contains all your global config. Save it in a "dotfiles" repo to restore your setup on a new machine.

Part of the Git Advanced guide

A

GitQuest is created by Anaïs (nouvelle fenêtre), web developer and head of education, specializing in tech training and digital accessibility.

Questions about git config

Configure Git and start practicing

Once Git is configured, dive into GitQuest investigations to learn commands in real-world scenarios.

Start the investigations