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

Re: Bug report: GIT_CONFIG and user.email/name

From
GLGerman Lashevich <german.lashevich@gmail.com>
Date
Jul 14, 2021, 18:26 UTC
Message-ID
<9A517A17-6BC6-4239-9CD5-F80C839C24F0@getmailspring.com>
In-Reply-To
<YO8ordiN18sNP6tA@coredump.intra.peff.net>
GIT_CONFIG is confusing, GIT_CONFIG_GLOBAL is what I need.
Thanks a lot! 
On Jul 14 2021, at 8:10 pm, Jeff King <peff@peff.net> wrote:
Show 45 quoted lines
> On Wed, Jul 14, 2021 at 07:10:27PM +0200, German Lashevich wrote:
> 
>> I've faced an issue while trying to use a non-default .gitconfig file
>> via specifying
>> GIT_CONFIG environment variable.
>> 
>> What did you do before the bug happened? (Steps to reproduce your issue)
>> 
>> ```
>> # use custom .gitconfig via GIT_CONFIG envvar:
>> mkdir -p /tmp/git-test/repo
>> cat <<EOT > /tmp/git-test/.gitconfig
>> [user]
>>     name = John Doe
>>     email = john@doe.me
>> EOT
>> cd /tmp/git-test/repo
>> git init
>> export GIT_CONFIG=/tmp/git-test/.gitconfig
>> echo Hi > readme.txt
>> git add readme.txt
>> git commit -m 'Initial commit'
>> ```
> 
> The GIT_CONFIG variable doesn't work that way. It is not a general
> mechanism used by all of Git, but rather a specific feature of the
> git-config program (and even there it is a historical wart; you should
> use "git config --file" instead).
> 
> One of these variables is probably more helpful:
> 
>  $ man git | sed -n '/GLOBAL/,/^$/p'
>  GIT_CONFIG_GLOBAL, GIT_CONFIG_SYSTEM
>    Take the configuration from the given files instead from global or
>    system-level configuration files. If GIT_CONFIG_SYSTEM is set, the
>    system config file defined at build time (usually /etc/gitconfig)
>    will not be read. Likewise, if GIT_CONFIG_GLOBAL is set, neither
>    $HOME/.gitconfig nor $XDG_CONFIG_HOME/git/config will be read. Can
>    be set to /dev/null to skip reading configuration files of the
>    respective level.
> 
> Note that they're new in v2.32.0.
> 
> -Peff
> 
Previous: Jeff KingNext: Junio C Hamano
Message 3 of 16 in “Bug report: GIT_CONFIG and user.email/name”
  1. German LashevichJul 14, 2021
  2. Jeff KingJul 14, 2021
  3. German LashevichJul 14, 2021
  4. Junio C HamanoJul 14, 2021
  5. Jeff KingJul 14, 2021
  6. 1/3 doc/git-config: explain --file instead of referring to GIT_CONFIGJeff King, Jul 14, 2021
  7. Taylor BlauJul 14, 2021
  8. Jeff KingJul 14, 2021
  9. Taylor BlauJul 14, 2021
  10. Martin ÅgrenJul 20, 2021
  11. Jeff KingJul 20, 2021
  12. Jeff KingJul 20, 2021
  13. Junio C HamanoJul 20, 2021
  14. 2/3 doc/git-config: clarify GIT_CONFIG environment variableJeff King, Jul 14, 2021
  15. 3/3 doc/git-config: simplify "override" advice for FILES sectionJeff King, Jul 14, 2021
  16. Taylor BlauJul 14, 2021

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.