Privacy Policy
© 2025 linux101.dev

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

shows the effective settings for your current repo, with local overrides applied

List global settings

git config --list --global

shows all settings of current global configuration

List local settings

git config --list --local

shows all settings of local configuration in current directory

Setting configuration values

General syntax for setting configuration values

git config [--system | --global | --local] key value

sets the given key to the given value in the specified configuration

General syntax for unsetting configuration values

git config [--system | --global | --local] --unset key

removes the given key from the specified configuration

General syntax for getting configuration values

git config [--system | --global | --local] key

retrieves 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 vimdiff

sets your default merge tool in global configuration

Set default push behavior

git config --global push.default simple

sets your default push behavior in global configuration

Set color output

git config --global color.ui auto

enables colored output in Git commands in global configuration

Set up an alias

git config --global alias.co checkout

creates a shortcut alias git co for git checkout in global configuration