Bug report: GIT_CONFIG and user.email/name
From: German Lashevich <hidden>
Date: 2021-07-14 17:10:33
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