{"thread":{"id":"49733","subject":"git appears to ignore GIT_CONFIG environment variable","startedAt":"2018-11-02T01:33:03Z","lastAt":"2018-11-03T17:58:12Z","messageCount":3,"participants":["Sirio Balmelli","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"362223","messageId":"3389BCF7-6170-4242-82D3-0FE7FB2EA5F2@gmail.com","threadId":"49733","inReplyTo":null,"subject":"git appears to ignore GIT_CONFIG environment variable","fromName":"Sirio Balmelli","fromEmail":"sirio.bm@gmail.com","sentAt":"2018-11-02T01:32:52Z","receivedAt":"2018-11-02T01:33:03Z","isPatch":false,"sender":{"key":"sirio.bm@gmail.com","avatar":null},"body":"It appears that git ignores the GIT_CONFIG environment variable, while git-config *does* consider it.\n\nI have written a short script that shows this in detail and reproduces, it is included below and also posted on github at https://github.com/siriobalmelli/toolbench/blob/master/git/git-env-check.sh\nThis behavior is confirmed in 2.17.1, 2.18.0 and 2.19.1\n\nI have tried to google this but don’t see any references to GIT_CONFIG outside of the git-config manual.\nIs it intended behavior that this environment variable is only valid with git-config?\n\nThank you very much,\n\nSirio\n\n—\n\n#!/bin/bash\n# this script demonstrates that the GIT_CONFIG is used by 'git-config'\n# but *not* by 'git' itself.\n# 2018 Sirio Balmelli\n\ncleanup()\n{\nrm -rf ~/.gitconfig git-env-check\n}\n\nfail()\n{\n\techo \"$*\" >&2\n\tcleanup\n\texit 1\n}\n\n# don't break the user's config\nif [[ -e ~/.gitconfig ]]; then\n\t# don't fail, deleting ~/.gitconfig, for obvious reasons\n\techo \"this script would break your existing ~/.gitconfig - please remove it and run again\" >&2\n\texit 1\nfi\n\nunset GIT_CONFIG\ngit config -l | grep -q alias.he=help \\\n\t&& fail \"alias 'he' already set, can't use it for this test\" \\\n\t|| echo \"1. the alias 'he' is unset by default\"\n\necho \"2. write a gitconfig in a non-standard location; export to GIT_CONFIG:\"\nmkdir git-env-check\ncat <<EOF | tee git-env-check/gitconfig\n[alias]\n  he = help\nEOF\nexport GIT_CONFIG=$(realpath git-env-check/gitconfig)\nenv | grep GIT_CONFIG\n\ngit config -l | grep -q alias.he=help \\\n\t|| fail \"unexpected: git-config doesn't see GIT_CONFIG\" \\\n\t&& echo \"3. git-config DID see 'he' from GIT_CONFIG\"\n\ngit he \\\n\t&& fail \"git does see GIT_CONFIG: please ignore this report\" \\\n\t|| echo \"4. git, however, did NOT see 'he'\"\n\nln -s $GIT_CONFIG ~/.gitconfig\ngit he >/dev/null \\\n\t|| fail \"unexpected: git also ignores ~/.gitconfig\" \\\n\t&& echo \"5. git DOES see 'he' if conf is linked to '~/.gitconfig'\"\n\necho \"6. this was $(git --version)\"\ncleanup\n\n"},{"id":"362230","messageId":"xmqqpnvoqirp.fsf@gitster-ct.c.googlers.com","threadId":"49733","inReplyTo":"3389BCF7-6170-4242-82D3-0FE7FB2EA5F2@gmail.com","subject":"Re: git appears to ignore GIT_CONFIG environment variable","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-11-02T03:07:38Z","receivedAt":"2018-11-02T03:07:45Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Sirio Balmelli <sirio.bm@gmail.com> writes:\n\n> It appears that git ignores the GIT_CONFIG environment variable,\n> while git-config *does* consider it.\n\nYup, that is exactly how it is designed and documented.  These\ndasys, with \"git config\" taking \"--file\" to work on any arbitrary\nfilename, you do not necessarily need GIT_CONFIG enviornment.\n\n"},{"id":"362374","messageId":"E62F9E2A-70F1-47A4-B30C-2C767102CDCC@gmail.com","threadId":"49733","inReplyTo":"xmqqpnvoqirp.fsf@gitster-ct.c.googlers.com","subject":"Re: git appears to ignore GIT_CONFIG environment variable","fromName":"Sirio Balmelli","fromEmail":"sirio.bm@gmail.com","sentAt":"2018-11-03T17:58:05Z","receivedAt":"2018-11-03T17:58:12Z","isPatch":false,"sender":{"key":"sirio.bm@gmail.com","avatar":null},"body":"Thank you very much, I appreciate the answer :)\n\nbest,\n\nSirio\n\n> On Nov 2, 2018, at 04:07, Junio C Hamano <gitster@pobox.com> wrote:\n> \n> Sirio Balmelli <sirio.bm@gmail.com> writes:\n> \n>> It appears that git ignores the GIT_CONFIG environment variable,\n>> while git-config *does* consider it.\n> \n> Yup, that is exactly how it is designed and documented.  These\n> dasys, with \"git config\" taking \"--file\" to work on any arbitrary\n> filename, you do not necessarily need GIT_CONFIG enviornment.\n> \n\n"}]}