# [QUESTION] How to add new configuration variable

5 messages from 2021-09-17 to 2021-09-17. Participants: Bagas Sanjaya, Konstantin Ryabitsev, Đoàn Trần Công Danh, Carlo Arenas, Junio C Hamano.
Thread: https://gitlist.dev/t/56521

## Bagas Sanjaya, 2021-09-17 10:44

Subject: [QUESTION] How to add new configuration variable
Message-ID: <9f3cc3f0-36db-f7e5-de1d-2c8c9f246884@gmail.com>
URL: https://gitlist.dev/e/9f3cc3f0-36db-f7e5-de1d-2c8c9f246884%40gmail.com

```
Hi,

Supposed that I'm writing git-foobar script ("git-foobar.sh"), which 
takes configuration variable "foobar.something" (string type).

How can I add that configuration variable so that it can be used by the 
script?

-- 
An old man doll... just what I always wanted! - Clara

```

## Konstantin Ryabitsev, 2021-09-17 13:43

Subject: Re: [QUESTION] How to add new configuration variable
Message-ID: <20210917134318.scdqa6k4swzgo5k2@meerkat.local>
URL: https://gitlist.dev/e/20210917134318.scdqa6k4swzgo5k2%40meerkat.local
In-Reply-To: <9f3cc3f0-36db-f7e5-de1d-2c8c9f246884@gmail.com>

```
On Fri, Sep 17, 2021 at 05:44:42PM +0700, Bagas Sanjaya wrote:
> Supposed that I'm writing git-foobar script ("git-foobar.sh"), which takes
> configuration variable "foobar.something" (string type).
> 
> How can I add that configuration variable so that it can be used by the
> script?

You can just add it. :) Git doesn't complain when it finds configuration
parameters it doesn't know anything about, it just ignores them.

E.g. in your .gitconfig or individual repository .git/config:

    [foobar]
        something = yourvalue

-K

```

## Đoàn Trần Công Danh, 2021-09-17 15:20

Subject: Re: [QUESTION] How to add new configuration variable
Message-ID: <YUSyNqd51euzvt8N@danh.dev>
URL: https://gitlist.dev/e/YUSyNqd51euzvt8N%40danh.dev
In-Reply-To: <20210917134318.scdqa6k4swzgo5k2@meerkat.local>

```
On 2021-09-17 09:43:18-0400, Konstantin Ryabitsev <konstantin@linuxfoundation.org> wrote:
> On Fri, Sep 17, 2021 at 05:44:42PM +0700, Bagas Sanjaya wrote:
> > Supposed that I'm writing git-foobar script ("git-foobar.sh"), which takes
> > configuration variable "foobar.something" (string type).
> > 
> > How can I add that configuration variable so that it can be used by the
> > script?
> 
> You can just add it. :) Git doesn't complain when it finds configuration
> parameters it doesn't know anything about, it just ignores them.
> 
> E.g. in your .gitconfig or individual repository .git/config:
> 
>     [foobar]
>         something = yourvalue

Or just:

	git config [--global] foobar.something yourvalue

-- 
Danh

```

## Carlo Arenas, 2021-09-17 16:21

Subject: Re: [QUESTION] How to add new configuration variable
Message-ID: <CAPUEspgv49ppMbwHMPjF6_4FBU1_tYk_DdXXOTDuWwAx74UL8Q@mail.gmail.com>
URL: https://gitlist.dev/e/CAPUEspgv49ppMbwHMPjF6_4FBU1_tYk_DdXXOTDuWwAx74UL8Q%40mail.gmail.com
In-Reply-To: <9f3cc3f0-36db-f7e5-de1d-2c8c9f246884@gmail.com>

```
you might want this in --global instead, but assuming it is ok to be
repository specific:

$ git config foobar.something baz

and in your script

  baz=$(git config foobar.something)

Carlo

```

## Junio C Hamano, 2021-09-17 20:02

Subject: Re: [QUESTION] How to add new configuration variable
Message-ID: <xmqqilyzgecx.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqqilyzgecx.fsf%40gitster.g
In-Reply-To: <YUSyNqd51euzvt8N@danh.dev>

```
Đoàn Trần Công Danh  <congdanhqx@gmail.com> writes:

> On 2021-09-17 09:43:18-0400, Konstantin Ryabitsev <konstantin@linuxfoundation.org> wrote:
>> On Fri, Sep 17, 2021 at 05:44:42PM +0700, Bagas Sanjaya wrote:
>> > Supposed that I'm writing git-foobar script ("git-foobar.sh"), which takes
>> > configuration variable "foobar.something" (string type).
>> > 
>> > How can I add that configuration variable so that it can be used by the
>> > script?
>> 
>> You can just add it. :) Git doesn't complain when it finds configuration
>> parameters it doesn't know anything about, it just ignores them.
>> 
>> E.g. in your .gitconfig or individual repository .git/config:
>> 
>>     [foobar]
>>         something = yourvalue
>
> Or just:
>
> 	git config [--global] foobar.something yourvalue

In addition to that, unless it is a script for your throw-away use
that we do not have to worry about, consider if the users of "git
foobar" needs to override a configured value with --no-something or
--something=anothervalue from the command line, and if so, make sure
these command line options are available to them.

```
