git config
Set user identity and preferences
Practical example
git config --global user.name "Your Name" git config --global user.email "you@example.com" git config --global init.defaultBranch main # Now every new repo defaults to 'main' instead of 'master'
Command overview & how it works
Stores configuration values at three levels: system (/etc/gitconfig), global (~/.gitconfig or ~/.config/git/config), and local (.git/config in the current repository). Each level overrides the previous. You must set your user.name and user.email before making your first commit — these are attached to every commit and are visible in the repository history. Use git config --global to apply settings across all repositories, git config --local (default) for per-project settings, and git config --system for machine-wide defaults. Common configurations include aliases (git config --global alias.co checkout), default branch name (init.defaultBranch main), and editor (core.editor "code --wait"). View all settings with git config --list.
Get the complete offline Git Field Guide
The 97-page PDF + ePub course — ₹499. Read this command, offline.
Practical tips
- Set user.name and user.email before your first commit — this identity is recorded in every commit you make.
- Local settings in .git/config override global settings in ~/.gitconfig, so you can override your identity per project.
- Check what is actually in effect with git config --list or a single value with git config user.name.
Deep-dive guides & tutorials
In-depth walkthroughs and practical scenarios related to git config
- Guide
How to Install Git on Windows, macOS, and Linux
A step-by-step setup guide covering every major platform, from Homebrew and Winget to package managers, plus verifying your install and configuring your identity.
7 min readRead guide - Tutorial
Git Basics Every Developer Should Know
Understand the core concepts — repositories, commits, branches, and remotes — before diving into the command line.
6 min readRead guide - Guide
How to Write Better Git Commit Messages
A practical guide to writing clear, conventional commit messages that make your project history readable and your team more productive.
6 min readRead guide
Related commands
More from Getting Started