# Configuration overrides via environment variable

4 messages from 2008-01-28 to 2008-01-28. Participants: David Symonds, Jan Hudec, Jakub Narebski.
Thread: https://gitlist.dev/t/11763

## David Symonds, 2008-01-28 01:08

Subject: Configuration overrides via environment variable
Message-ID: <ee77f5c20801271708k124dc9d7n942b3c95299cb7fb@mail.gmail.com>
URL: https://gitlist.dev/e/ee77f5c20801271708k124dc9d7n942b3c95299cb7fb%40mail.gmail.com

```
Hi,

I'm using Git in some scripts, and wanted to get its colorised output
even when it is not going to a tty. I don't want to permanently change
~/.gitconfig or the per-repo config; I just want to set color.status
(and perhaps others) to "always" for a one-off run. I suppose I could
munge the config files, storing the previous value and restoring it
later, but that's messy.

Ideally, an environment variable like GIT_EXTRA_CONFIG or something
would be nice, so I could just do:

GIT_EXTRA_CONFIG="color.status=always" git status | ...

Thoughts? Does this already exist, and I've overlooked it?


Dave.

```

## Jan Hudec, 2008-01-28 20:58

Subject: Re: Configuration overrides via environment variable
Message-ID: <20080128205837.GB5788@efreet.light.src>
URL: https://gitlist.dev/e/20080128205837.GB5788%40efreet.light.src
In-Reply-To: <ee77f5c20801271708k124dc9d7n942b3c95299cb7fb@mail.gmail.com>

```
On Mon, Jan 28, 2008 at 12:08:10 +1100, David Symonds wrote:
> Hi,
> 
> I'm using Git in some scripts, and wanted to get its colorised output
> even when it is not going to a tty. I don't want to permanently change
> ~/.gitconfig or the per-repo config; I just want to set color.status
> (and perhaps others) to "always" for a one-off run. I suppose I could
> munge the config files, storing the previous value and restoring it
> later, but that's messy.
> 
> Ideally, an environment variable like GIT_EXTRA_CONFIG or something
> would be nice, so I could just do:
> 
> GIT_EXTRA_CONFIG="color.status=always" git status | ...
> 
> Thoughts? Does this already exist, and I've overlooked it?

Quickly looking at the git-config manpage, there does not seem to be a way to
provide alternate config file via GIT_CONFIG and/or GIT_CONFIG_LOCAL
variables. I don't know how good match for your problem that would be.

-- 
						 Jan 'Bulb' Hudec <bulb@ucw.cz>

```

## Jakub Narebski, 2008-01-28 22:58

Subject: Re: Configuration overrides via environment variable
Message-ID: <m3tzkx8smg.fsf@localhost.localdomain>
URL: https://gitlist.dev/e/m3tzkx8smg.fsf%40localhost.localdomain
In-Reply-To: <20080128205837.GB5788@efreet.light.src>

```
Jan Hudec <bulb@ucw.cz> writes:

> On Mon, Jan 28, 2008 at 12:08:10 +1100, David Symonds wrote:
> > 
> > I'm using Git in some scripts, and wanted to get its colorised output
> > even when it is not going to a tty. I don't want to permanently change
> > ~/.gitconfig or the per-repo config; I just want to set color.status
> > (and perhaps others) to "always" for a one-off run. I suppose I could
> > munge the config files, storing the previous value and restoring it
> > later, but that's messy.

Cannot you just use --color option?
 
> > Ideally, an environment variable like GIT_EXTRA_CONFIG or something
> > would be nice, so I could just do:
> > 
> > GIT_EXTRA_CONFIG="color.status=always" git status | ...
> > 
> > Thoughts? Does this already exist, and I've overlooked it?
> 
> Quickly looking at the git-config manpage, there does not seem to be a way to
> provide alternate config file via GIT_CONFIG and/or GIT_CONFIG_LOCAL
> variables. I don't know how good match for your problem that would be.

GIT_CONFIG_LOCAL *replaces* repository configuration file; the global
and the system-wide configuration files will still be read. GIT_CONFIG
is the only config file read.

So you could I guess concatenate repo config with "[color] status=always",
although you would get warnings if color.status is already set...

-- 
Jakub Narebski
Poland
ShadeHawk on #git

```

## David Symonds, 2008-01-28 23:11

Subject: Re: Configuration overrides via environment variable
Message-ID: <ee77f5c20801281511md7bdeeme383a140fdc854ec@mail.gmail.com>
URL: https://gitlist.dev/e/ee77f5c20801281511md7bdeeme383a140fdc854ec%40mail.gmail.com
In-Reply-To: <m3tzkx8smg.fsf@localhost.localdomain>

```
On Jan 29, 2008 9:58 AM, Jakub Narebski <jnareb@gmail.com> wrote:
> Jan Hudec <bulb@ucw.cz> writes:
>
> > On Mon, Jan 28, 2008 at 12:08:10 +1100, David Symonds wrote:
> > >
> > > I'm using Git in some scripts, and wanted to get its colorised output
> > > even when it is not going to a tty. I don't want to permanently change
> > > ~/.gitconfig or the per-repo config; I just want to set color.status
> > > (and perhaps others) to "always" for a one-off run. I suppose I could
> > > munge the config files, storing the previous value and restoring it
> > > later, but that's messy.
>
> Cannot you just use --color option?

My version of Git (1.5.3.8) doesn't have a --color option for
git-status, and I can't find support for it in 'next', either. It
would be ideal if there was a --color option, though.


Dave.

```
