Lesson Completion
Back to course

Config Levels

Beginner
7 minutes4.7Git

The Hook (The "Byte-Sized" Intro)

Git doesn't have one config — it has three layers that stack on top of each other. System covers every user on the machine. Global covers everything you do. Local overrides both for one specific repo. Understanding this cascade explains why your name shows up wrong in certain repos and how to fix it in seconds.

📖 What are Config Levels?

Git configuration is stored at three levels: system, global, and local. Each level overrides the one above it — local wins over global, global wins over system.

Conceptual Clarity

The three levels:

LevelScopeFile LocationFlag
SystemAll users on the machine/etc/gitconfig--system
GlobalCurrent user, all repos~/.gitconfig--global
LocalCurrent repository only.git/config--local

Override order (highest priority wins):

Local → overrides → Global → overrides → System

Why this matters: You can set your personal email globally but override it with a work email in company repos using local config.

Real-Life Analogy

Config levels are like dress codes. The building has a general rule (system), your floor has its own rule (global), and your meeting room can override both (local). The most specific rule always wins.

Visual Architecture

flowchart TD SYSTEM["🖥️ System<br/>/etc/gitconfig"] --> GLOBAL["👤 Global<br/>~/.gitconfig"] GLOBAL --> LOCAL["📁 Local<br/>.git/config"] LOCAL --> FINAL["✅ Effective Config"] style SYSTEM fill:#1a1a2e,stroke:#53d8fb,color:#53d8fb style GLOBAL fill:#0f3460,stroke:#53d8fb,color:#53d8fb style LOCAL fill:#1b2d1b,stroke:#ffd700,color:#ffd700 style FINAL fill:#1b2d1b,stroke:#53d8fb,color:#53d8fb

Why It Matters

  • Flexibility: Different settings for different repos (work vs personal).
  • Debugging: When config behaves unexpectedly, check all three levels.
  • Organization: Global for preferences, local for project-specific overrides.
  • Team consistency: Local config can enforce project standards.

Code

bash
# ─── View config at each level ─── git config --system --list # System config git config --global --list # Global config git config --local --list # Local config (in a repo) # ─── See where a value comes from ─── git config --show-origin user.email # file:/home/user/.gitconfig jane@personal.com # ─── Set at different levels ─── git config --global user.name "Jane Doe" git config --local user.email "jane@company.com" # ─── Override for a work repo ─── cd ~/work/project git config --local user.email "jane@company.com" # This repo now uses the work email # ─── View all effective config ─── git config --list --show-origin # Shows every setting and which file it comes from

Key Takeaways

  • Git has 3 config levels: system, global, local — local wins.
  • Use --show-origin to debug where a setting comes from.
  • Set personal defaults globally; override per-repo with local config.
  • git config --list --show-origin shows the full picture.

Interview Prep

  • Q: What are the three levels of Git configuration? A: System (/etc/gitconfig, all users), Global (~/.gitconfig, current user), and Local (.git/config, current repo). Local overrides Global, which overrides System.

  • Q: How do you use different emails for different repos? A: Set your personal email with git config --global user.email "personal@email.com" and override it in work repos with git config --local user.email "work@email.com".

  • Q: How do you debug where a Git config value comes from? A: git config --show-origin <key> shows the file that set the value. git config --list --show-origin shows all settings with their source files.

Topics Covered

Git ConfigurationGit Setup

Tags

#git#config#setup#beginner

Last Updated

2026-02-13