8

In what git version became the git config --local option available, and where can I read more about it?

I thought that not providing --global will automatically assume that it's a local config variable. Why was this new option necessary?

ThinkingStiff
  • 64,767
  • 30
  • 146
  • 239
András Szepesházi
  • 6,483
  • 5
  • 45
  • 59

2 Answers2

10

Since the git sources are maintained in git, we can find the revision that introduced the --local option:

commit 57210a678a8bedd222bf4478eeb0a664d9dd5369
Author: Sverre Rabbelier <srabbelier@gmail.com>
Date:   2010-08-03 20:59:23 -0500

    config: add --local option

    This is a shorthand similar to --system but instead uses
    the config file of the current repository.

It appears that this change first appeared in release 1.7.4 which came out in late 2010 or so.

As far as I can tell from a quick look at the source code (builtin/config.h) and man page, the default is local unless certain environment variables are set, particularly $GIT_CONFIG. The --local option explicitly overrides any environment variable settings.

See VonC's answer for more information on the semantics of --local (the documentation was updated after I originally posted this answer).

Community
  • 1
  • 1
Keith Thompson
  • 254,901
  • 44
  • 429
  • 631
7

Note that the description for that --local option has only recently (June 2013, three years later) been updated:

Commit 560d4b86abc547dfb10b116ab99c800d68ae8849:

config: Add description of --local option

It was missed in the option list while mentioned from the general description.
Add it for completeness.

The description is now:

--local::
  • For writing options: write to the repository .git/config file.
    This is the default behavior.
  • For reading options: read only from the repository .git/config rather than from all available files.
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250