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

Bug report: GIT_CONFIG and user.email/name

From
GLGerman Lashevich <german.lashevich@gmail.com>
Date
Jul 14, 2021, 17:10 UTC
Message-ID
<1C6C1E49-5EC1-420D-A72A-8C50BD1931A2@getmailspring.com>
Hello,

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'
```

What did you expect to happen? (Expected behavior) Git creates a new commit.

What happened instead? (Actual behavior) Error occurred:

``` Author identity unknown

*** Please tell me who you are.
Run
  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity. Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'john@computer.(none)') ```

What's different between what you expected and what actually happened? For some reason `git commit` doesn't use configuration options specified in the custom `.gitconfig` file.

Anything else you want to add: `git config` shows correct values:

```
sh-5.1$ pwd
/tmp/git-test/repo
sh-5.1$ echo $GIT_CONFIG
/tmp/git-test/.gitconfig
sh-5.1$ cat $GIT_CONFIG
[user]
    name = John Doe
    email = john@doe.me
sh-5.1$ git config user.name
John Doe
sh-5.1$ git config user.email
john@doe.me
```
The same happens with git version 2.32.0.432.gabb21c7263

[System Info] git version: git version 2.32.0 cpu: x86_64 no commit associated with this build sizeof-long: 8 sizeof-size_t: 8 shell-path: /bin/sh uname: Linux 5.12.15-arch1-1 #1 SMP PREEMPT Wed, 07 Jul 2021 23:35:29 +0000 x86_64 compiler info: gnuc: 11.1 libc info: glibc: 2.33 $SHELL (typically, interactive shell): /bin/zsh

Next: Jeff King
Message 1 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.