Short answer:

  1. .git/config in your active git repository;
  2. ~/.gitconfig or ~/.config/git;
  3. /etc/gitconfig

More detailed answer can be found in the git man page:

If not set explicitly with –file, there are four files where git config will search for configuration options:

System-wide configuration file.

Second user-specific configuration file. If $XDG_CONFIG_HOME is not set or empty, $HOME/.config/git/config will be used. Any single-valued variable set in this file will be overwritten by whatever is in ~/.gitconfig. It is a good idea not to create this file if you sometimes use older versions of Git, as support for this file was added fairly recently.

User-specific configuration file. Also called “global” configuration file.

Repository specific configuration file.

If no further options are given, all reading options will read all of these files that are available. If the global or the system-wide configuration file are not available they will be ignored. If the repository configuration file is not available or readable, git config will exit with a non-zero error code. However, in neither case will an error message be issued.

The files are read in the order given above, with last value found taking precedence over values read earlier. When multiple values are taken then all values of a key from all files will be used.

All writing options will per default write to the repository specific configuration file. Note that this also affects options like –replace-all and –unset. git config will only ever change one file at a time.

You can override these rules either by command-line options or by environment variables. The –global and the –system options will limit the file used to the global or system-wide file respectively. The GIT_CONFIG environment variable has a similar effect, but you can specify any filename you want.

Tagged with:

One Response to Where is git config file?

  1. ench0 says:

    .. and while we’re at it – let’s also see where is gitk’s config file:

    This will be particularly useful to those used to gitk’s older color scheme where the branch names were displayed on a much lighter background and consequently (IMO) – much easier to read. More recent versions of gitk use a dark green background making the branch name, (in black letters) is hard to read.

    So if you want to change this – open the gitk config file in your favorite text editor and search for:

        set headbgcolor green

    Change it to:

        set headbgcolor lightgreen
    and off you go 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

Set your Twitter account name in your settings to use the TwitterBar Section.