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

BUG: git config --global --get ITEM ignores ~/.config/git/config when ~/.gitconfig is present

From
JLJade Lovelace <lists@jade.fyi>
Date
Feb 11, 2023, 00:39 UTC
Message-ID
<CAFA9we-QLQRzJdGMMCPatmfrk1oHeiUu9msMRXXk1MLE5HRxBQ@mail.gmail.com>
Dear maintainers,

I have found what I think is a bug or at least a documentation flaw in git-config: when both ~/.gitconfig and ~/.config/git/config exist, `git config` can retrieve items set in the latter, but not with the `--global` flag set. For context, I use ~/.gitconfig as a non-checked-in machine-specific config, and ~/.config/git/config as my checked-in all-machines configuration file.

The documentation states:
> When reading, the values are read from the system, global and repository local configuration files by default, and options --system, --global, --local, --worktree and --file can be used to tell the command to read from only that location (see the section called “FILES”).
Show 5 quoted lines
> FILES
>        $XDG_CONFIG_HOME/git/config, ~/.gitconfig
>           User-specific configuration files. When the XDG_CONFIG_HOME environment variable is not set or empty, $HOME/.config/ is used as $XDG_CONFIG_HOME.
>
>           These are also called "global" configuration files. If both files exist, both files are read in the order given above.

Based on this documentation, I would expect `--global` to consider both global configuration files, but it does not.

Reproduction:

Set some setting in ~/.config/git/config, say: [pull] ff = only

Ensure that ~/.gitconfig exists.
Then:
 » git config --global --get user.name
 » git config --show-scope --show-origin --get user.name
global  file:/home/jade/.config/git/config      Jade Lovelace

» git --version git version 2.39.1

Regards, Jade

Next: Junio C Hamano
Message 1 of 7 in “BUG: git config --global --get ITEM ignores ~/.config/git/config when ~/.gitconfig is present”
  1. Jade LovelaceFeb 11, 2023
  2. Junio C HamanoFeb 11, 2023
  3. Jade LovelaceFeb 11, 2023
  4. Junio C HamanoFeb 11, 2023
  5. Junio C HamanoFeb 11, 2023
  6. Glen ChooFeb 15, 2023
  7. Junio C HamanoFeb 15, 2023

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.