Re: Bug report: GIT_CONFIG and user.email/name
- From
Jeff King <peff@peff.net>
- Date
- Jul 14, 2021, 18:10 UTC
- Message-ID
- <YO8ordiN18sNP6tA@coredump.intra.peff.net>
- In-Reply-To
- <1C6C1E49-5EC1-420D-A72A-8C50BD1931A2@getmailspring.com>
On Wed, Jul 14, 2021 at 07:10:27PM +0200, German Lashevich wrote:
Show 21 quoted lines
> 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