basics

git config

Reads and writes Git configuration variables at system, global, or repository scope. Controls identity, aliases, editor, merge tools, and much more.

git config [<location>] <key> [<value>]

Common flags

Flag Purpose
--global Read/write per-user config in ~/.gitconfig
--local Read/write repository config in .git/config (default)
--system Read/write machine-wide config
--list Show all configured settings
--unset <key> Remove a configured value
--edit Open the config file in your editor

Examples

git config --global user.email "[email protected]"

Set your commit identity globally

git config --global alias.co checkout

Create an alias so 'git co' works

git config --global pull.rebase true

Make 'git pull' rebase by default

Gotcha

Local config always overrides global; if a setting seems wrong, check .git/config in the repo before editing ~/.gitconfig.

Related commands

← All Git commands · Git cheat sheet · Git rebase vs merge