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.
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.