git config

Get and set repository or global options

Git config allows you to view, add or edit git configuration. These configurations contain information about your user, repositories, aliases etc. Try and view them with git config -l

Layer 1
Terminal Example
git config -l
credential.helper=osxkeychain
user.name=Githint User
alias.recent=branch --sort=-committerdate --format="%(committerdate:relative)%09%(refname:short)"
alias.st=status
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=true
core.editor=subl

Each line contains a configuration, starting with a name followed by the configured value (after '='). Individual config values can be read with git config config.name and are stored on three different levels:

  • - System level: applied to every user on the system and every repository. To list them run git config --list --system
  • - Global level: specific to your user only. To list them run git config --list --global
  • - Repository level: specific to a single repository. To list them run git config --list --local

Changing the configurations

You can add a new configuration with git config config.key value. By default a local configuration is created, which you can override with additional --global and --system options.

Layer 1
Terminal Example
git config alias.st status
git config alias.st
status

Updating an existing configuration is similar to addition: git config config.key config.value.

Layer 1
Terminal Example
git config alias.st
status
git config alias.st stash
git config alias.st
stash

You can also edit multiple configurations at once by editing the config file with git config --edit. Use options --global or --system to edit the global or system level config files.

You can remove a configuration with git config --unset config.key

Layer 1
Terminal Example
git config --unset alias.st

You can read more about the command in the official documentation.

How-tos using git config

Last modified on November 30, 2021.

Can't find a solution to your git problem?

Contact us on githint@githint.com and we will add the solution to the site