git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: German Lashevich <german.lashevich@gmail.com>
Cc: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: Bug report: GIT_CONFIG and user.email/name
Date: Wed, 14 Jul 2021 14:10:53 -0400	[thread overview]
Message-ID: <YO8ordiN18sNP6tA@coredump.intra.peff.net> (raw)
In-Reply-To: <1C6C1E49-5EC1-420D-A72A-8C50BD1931A2@getmailspring.com>

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

  reply	other threads:[~2021-07-14 18:10 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-14 17:10 Bug report: GIT_CONFIG and user.email/name German Lashevich
2021-07-14 18:10 ` Jeff King [this message]
2021-07-14 18:26   ` German Lashevich
2021-07-14 20:47   ` Junio C Hamano
2021-07-14 21:36     ` Jeff King
2021-07-14 21:37       ` [PATCH 1/3] doc/git-config: explain --file instead of referring to GIT_CONFIG Jeff King
2021-07-14 22:20         ` Taylor Blau
2021-07-14 22:23           ` Jeff King
2021-07-14 22:26             ` Taylor Blau
2021-07-20 19:34         ` Martin Ågren
2021-07-20 20:01           ` Jeff King
2021-07-20 20:03             ` Jeff King
2021-07-20 21:55             ` Junio C Hamano
2021-07-14 21:38       ` [PATCH 2/3] doc/git-config: clarify GIT_CONFIG environment variable Jeff King
2021-07-14 21:38       ` [PATCH 3/3] doc/git-config: simplify "override" advice for FILES section Jeff King
2021-07-14 22:22       ` Bug report: GIT_CONFIG and user.email/name Taylor Blau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YO8ordiN18sNP6tA@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=german.lashevich@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).