什么时候git为git config命令引入了"--local"开关?

And*_*ázi 8 git git-config

在哪个git版本成为git config --local可用选项,我在哪里可以阅读更多相关信息?

我认为不提供--global将自动假设它是一个本地配置变量.为什么这个新选项是必要的?

Kei*_*son 10

由于git源是在git中维护的,我们可以找到引入该--local选项的修订:

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.
Run Code Online (Sandbox Code Playgroud)

看起来这种变化最初出现在2010年末出版的1.7.4版本中.

据我所知,通过快速查看源代码(builtin/config.h)和手册页,除非设置了某些环境变量,否则缺省值是local $GIT_CONFIG.该--local选项显式覆盖任何环境变量设置.

有关语义的更多信息,请参阅VonC的答案--local(文档在我最初发布此答案后更新).


Von*_*onC 7

请注意,该--local选项的描述仅在最近(2013年6月,三年后)更新:

提交560d4b86abc547dfb10b116ab99c800d68ae8849:

config:添加--local选项说明

从一般描述中提到时,它在选项列表中被遗漏了.
添加它是为了完整性.

现在描述:

--local::
Run Code Online (Sandbox Code Playgroud)
  • 对于写入选项:写入存储库.git/config文件.
    这是默认行为.
  • 对于读取选项:只读取存储库.git/config而不是所有可用文件.