Chapter 3: Git Config
Git Config! ☕
This is one of those topics that feels boring at first (“just name and email, right?”), but once you understand it properly, it becomes your secret superpower. You’ll customize Git exactly how you like it, avoid 100 common frustrations, and look like a pro when someone asks “how did you make git log look so beautiful?”
Think of git config as Git’s settings menu — but way more powerful than any app settings page.
What does git config actually do?
It lets you read, set, change, or delete hundreds of tiny switches that control:
- How Git behaves (line endings, compression, safety checks…)
- How it looks (colors, log format…)
- Your identity (who appears in commits)
- Shortcuts (aliases like git lg for pretty log)
- Default tools (editor, credential helper…)
- Team conventions (default branch name, pull behavior…)
Git reads these settings from three layered levels (like onion layers — inner ones win).
The Famous 3 Levels of Git Config (2026 reality)
| Level | Flag | File location (typical) | Applies to … | Who usually changes it? | Precedence (who wins?) |
|---|---|---|---|---|---|
| System | –system | /etc/gitconfig (Linux) C:\ProgramData\Git\config (Windows) | All users on this computer | Admin / company IT | Lowest (overridden by others) |
| Global | –global | ~/.gitconfig or ~/.config/git/config Windows: C:\Users\YourName\.gitconfig | You — all your repositories | You (99% of what you’ll touch) | Medium |
| Local | –local (default if inside repo) | .git/config (inside your project folder) | Only this one repository | You — when project needs special rules | Highest — overrides everything |
Rule to remember forever: Local > Global > System (closest to the repo wins)
Real example – see it in action
Create a playground folder:
|
0 1 2 3 4 5 6 7 8 |
mkdir git-config-demo cd git-config-demo git init |
Now let’s set things at different levels.
-
System level (rarely touched — pretend you’re admin)
Bash01234567# You need sudo / admin rightsgit config --system user.name "Company Default User"→ Affects every Git user on this machine (unless overridden)
-
Global level (your personal defaults)
Bash0123456789git config --global user.name "Webliance"git config --global user.email "webliance@example.com"git config --global init.defaultBranch main # very important in 2026!git config --global core.editor "code --wait" # VS Code as commit editor -
Local level (only this repo)
Inside the repo folder:
Bash01234567git config user.name "Webliance - Work Project Mode"git config user.email "work@company.in"
Now let’s see what’s really being used:
|
0 1 2 3 4 5 6 7 |
# Show everything + where it comes from (super useful!) git config --list --show-origin |
Typical output looks like this (example from a real setup):
|
0 1 2 3 4 5 6 7 8 9 10 11 12 |
file:C:/Users/Webliance/.gitconfig user.name=Webliance file:C:/Users/Webliance/.gitconfig user.email=webliance@example.com file:C:/Users/Webliance/.gitconfig init.defaultBranch=main file:C:/Users/Webliance/.gitconfig core.editor=code --wait file:.git/config user.name=Webliance - Work Project Mode file:.git/config user.email=work@company.in file:C:/ProgramData/Git/config core.autocrlf=true # system default on Windows |
See? The local user.name & email override the global ones — only for this repo!
Most Useful / Popular Settings (2026 edition)
Here are the ones almost every developer sets globally:
|
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# Identity (must do first!) git config --global user.name "Your Full Name" git config --global user.email "your-real-email@gmail.com" # Modern default branch (since ~2020-2022 shift) git config --global init.defaultBranch main # Better looking UI git config --global color.ui auto # Make git status / diff nicer git config --global core.autocrlf input # Linux/macOS # or git config --global core.autocrlf true # Windows (most common) # Faster operations git config --global core.preloadindex true git config --global core.fscache true # Windows especially # When you git commit, show diff in editor (helps avoid bad commits) git config --global commit.verbose true # Pull always rebase instead of merge (cleaner history – very popular now) git config --global pull.rebase true # Auto correct minor typos (git staus → git status) git config --global help.autocorrect 10 # Pretty log alias (my favorite!) git config --global alias.lg "log --graph --oneline --decorate --all" # Now just type: git lg |
How to edit config files directly (sometimes easier)
|
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
# Edit global config in your default editor git config --global --edit # Edit local config git config --edit # Or just open the file # Windows: notepad ~/.gitconfig # macOS/Linux: code ~/.gitconfig or nano ~/.gitconfig |
It looks like this (INI format):
|
0 1 2 3 4 5 6 7 8 9 10 11 12 |
[user] name = Webliance email = webliance@example.com [alias] lg = log --graph --oneline --decorate --all [core] editor = code --wait |
Quick Commands Cheat Sheet
| What you want to do | Command Example |
|---|---|
| See all settings (with source file) | git config –list –show-origin |
| See only global | git config –global –list |
| See only this repo | git config –local –list |
| Get one value | git config user.name |
| Set one value | git config –global core.editor “nano” |
| Unset / remove one | git config –global –unset alias.bad |
| Edit full file | git config –global –edit |
| List all possible settings (huge!) | git help –config |
Mini homework – try right now!
-
Run git config –list –show-origin → see what you already have!
-
Add the pretty log alias:
Bash0123456git config --global alias.lg "log --graph --oneline --decorate --all" -
In any repo, type git lg → beautiful branch graph!
Any part confusing?
- Want to see how to fix line-ending hell on Windows?
- Need help creating useful aliases?
- Or shall we talk about credential helpers for GitHub login without typing password every time?
Just shout — we’ll keep going step by step. You’re getting really good at this! 🚀
