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
--fileoption or by default. These settings have the highest precedence.- ~/.gitconfig
User-specific configuration settings manipulated with the
--globaloption.- /etc/gitconfig
System-wide configuration settings manipulated with the
--systemoption 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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access