Git: Config
Git configuration is stored in three levels: system, global, and local. Each level overrides the previous one, with local settings taking precedence over global, and global over system.
Git stores configuration settings in the configuration hierarchy:
- system → applies to all users on the machine
- global → applies to your user (~/.gitconfig)
- local → applies only to the repository (.git/config) — this takes precedence
Viewing current configuration
List effective settings
git config --listshows the effective settings for your current repo, with local overrides applied
List global settings
git config --list --globalshows all settings of current global configuration
List local settings
git config --list --localshows all settings of local configuration in current directory
Setting configuration values
General syntax for setting configuration values
git config [--system | --global | --local] key valuesets the given key to the given value in the specified configuration
General syntax for unsetting configuration values
git config [--system | --global | --local] --unset keyremoves the given key from the specified configuration
General syntax for getting configuration values
git config [--system | --global | --local] keyretrieves the value of the given key from the specified configuration
Common configuration settings
Set your name for commits
git config --global user.name "Your Name"sets your name for commits in global configuration
Set your email for commits
git config --global user.email "you@example.com"sets your email for commits in global configuration
Set default text editor
git config --global core.editor "code --wait"sets your default text editor for commit messages and other prompts in global configuration
Set default merge tool
git config --global merge.tool vimdiffsets your default merge tool in global configuration
Set default push behavior
git config --global push.default simplesets your default push behavior in global configuration
Set color output
git config --global color.ui autoenables colored output in Git commands in global configuration
Set up an alias
git config --global alias.co checkoutcreates a shortcut alias git co for git checkout in global configuration