O'Reilly logo

Version Control with Git by Jon Loeliger

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Configuration Files

Git’s configuration files are all simple text files in the style of .ini files. They record various choices and settings used by many Git commands. Some settings represent purely personal preferences (should a color.pager be used?); others are vital to a repository functioning correctly (core.repositoryformatversion), while still others tweak command behavior a bit (gc.auto).

Like many tools, Git supports a hierarchy of configuration files. In decreasing precedence, they are:

.git/config

Repository-specific configuration settings manipulated with the --file option or by default. These settings have the highest precedence.

~/.gitconfig

User-specific configuration settings manipulated with the --global option.

/etc/gitconfig

System-wide configuration settings manipulated with the --system option if you have proper Unix file write permissions on it. These settings have the lowest precedence. Depending on your actual installation, the system settings file might be somewhere else, like /usr/local/etc/gitconfig, or it might be entirely absent.

For example, to establish an author name and email address that will be used on all the commits that you make for all of your repositories, configure values for user.name and user.email in your $HOME/.gitconfig file using git config --global:

$ git config --global user.name "Jon Loeliger"
$ git config --global user.email "jdl@example.com"

Or, to set a repository-specific name and email address that would override a --global setting, simply ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required