git config
Configure Git settings at global, repository, or system level, customizing behavior and credentials.
Git needs to know who you are when you make commits, and you want to customize
how it behaves. git config sets configuration values that control everything
from your identity to default branch names to merge strategies. These settings
live at three levels: system (all users), global (your user account), and local
(specific repository).
The first thing you configure after installing Git is your identity:
git config --global user.name "Your Name" and
git config --global user.email "your@email.com". These values appear in every
commit you make. Using --global sets them for all repositories on your
machine. Omit --global to set them only for the current repository, which is
useful if you use different emails for work and personal projects.
To see all your current settings, run git config --list. For a specific value,
use git config user.name. To change a value, use git config <key> <value>.
To remove a value, use git config --unset <key>.
Common configurations include setting your default editor
(git config --global core.editor vim), configuring line ending handling
(git config --global core.autocrlf true), and setting the default branch name
for new repositories (git config --global init.defaultBranch main).
You can create aliases for frequently used commands:
git config --global alias.co checkout lets you type git co instead of
git checkout. More complex aliases can combine multiple commands:
git config --global alias.lg "log --graph --oneline --all" creates a custom
log format.
Configuration files live in .git/config (repository level), ~/.gitconfig
(global level), or system paths (system level). You can edit these files
directly instead of using git config commands, though using the command is
safer as it validates syntax.
Understanding config means customizing Git to match your workflow. Settings control how Git behaves, from simple preferences like colors and aliases to critical settings like merge strategies and credential storage. Taking time to configure Git properly makes daily work smoother.
