git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: What is XDG_CONFIG_HOME for exactly?

From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
Date
Mar 16, 2015, 09:31 UTC
Message-ID
<vpqvbi1qodw.fsf@anie.imag.fr>
In-Reply-To
<CAHd499AGHgBECH9t_EtkwLx7VCx3yVnDS27PteF3zF1xSAG8Yg@mail.gmail.com>
Show 6 quoted lines
> On Sun, Mar 15, 2015 at 6:37 PM, Robert Dailey <rcdailey.lists@gmail.com> wrote:
>> My understanding is that git reads the priority of configuration as follows:
>>
>> 1. <local_repo>/.git/config
>> 2. $HOME/.gitconfig
>> 3. $XDG_CONFIG_HOME/git/config

$HOME/.gitconfig is the traditional Unix location for config files. It was the only per-user config files in early versions of Git.

$XDG_CONFIG_HOME/git/config is the location following freedesktop's XDG standard. It has several advantages (you can version and/or share individual $XDG_CONFIG_HOME/git/ as a whole directory, while it's much harder to version all ~/.git* files individually for example).

You typically want to use either one or the other.
>> 4. system level git config (not sure exactly where this is; not
>> relevant to me on Windows)

This is relevant if you use a shared machine and your sysadmin wants to have the same configuration for all users.

> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Robert Dailey <rcdailey.lists@gmail.com> writes:
Show 7 quoted lines
> As a follow-up, I tested the following in my .bashrc:
>
>
> # Utilize different GIT settings based on platform
> if [[ $OSTYPE == 'msys' || $OSTYPE == 'cygwin' ]]; then
>     echo 'Using WINDOWS specific git settings'
>     export XDG_CONFIG_HOME=.config-windows
You need an absolute directory here:
export XDG_CONFIG_HOME=$HOME/.config-windows
Then, I'd suggest that $XDG_CONFIG_HOME/git/config contains a
[include]
    path = ../../.config-shared/git/config

so that you can factor out common portions of your config file into .config-shared/git/config and keep machine-specific portions in ~/.config-{windows,linux}.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Previous: Robert Dailey
Message 4 of 4 in “What is XDG_CONFIG_HOME for exactly?”
  1. Robert DaileyMar 15, 2015
  2. Robert DaileyMar 15, 2015
  3. Robert DaileyMar 15, 2015
  4. Matthieu MoyMar 16, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.