Home / Configs / Developer tools / .gitconfig setup

.gitconfig example: set your name, email and shortcuts

Set your name, email, default branch and shortcuts once.

For Git 2.28 or newer on any system. On Windows the file is C:\Users\YourName\.gitconfig.

The .gitconfig file stores your Git settings once so every project uses them. Enter your name and email below to build the file, then place it in your home folder.

Create your config file

Type your own values. The file below updates as you type, and nothing you type leaves your browser.

~/.gitconfig
[user]
  name = Your Name
  email = you@example.com
[init]
  defaultBranch = main
[core]
  editor = code --wait
  autocrlf = input
[pull]
  rebase = false
[alias]
  st = status -sb
  lg = log --oneline --graph --decorate
  undo = reset --soft HEAD~1

How this setup works

Diagram: git commit, then ~/.gitconfig, then Every repo
git commit (needs your name) → ~/.gitconfig (global settings) → Every repo (uses them)

Step-by-step setup

  1. Open a terminal.
  2. Run git config --global --edit.
  3. Paste the config above into ~/.gitconfig.
  4. Check it: git config user.email should print you@example.com.

What the important lines mean

Common errors and how to fix them

Please tell me who you are
Name and email are missing. Add the [user] block.
Commits show the wrong email
A repo-level setting overrides this file. Run git config user.email inside the repo to check.

Frequently asked questions

Where is the .gitconfig file?
In your home folder: ~/.gitconfig on Linux and macOS, and C:\Users\YourName\.gitconfig on Windows. Run git config --global --edit to open it.
How do I set my name and email in Git?
Run git config --global user.name "Your Name" and git config --global user.email "you@example.com", or use the file generated above.
How do I use a different email for work projects?
Add an includeIf block that loads a second config file for your work folder, for example [includeIf "gitdir:~/work/"], and put the work email in that file.

Written for: Git 2.45, Windows 11, macOS 14, Ubuntu 24.04 · Updated 2026-10-02

Fix a problem with this setup

More developer configs

See all 41 config generators