【问题标题】:When did git introduce the "--local" switch for git config command?git 什么时候为 git config 命令引入了“--local”开关?
【发布时间】:2012-03-26 19:54:17
【问题描述】:

在哪个 git 版本中,git config --local 选项可用,我在哪里可以阅读更多关于它的信息?

我认为不提供--global 会自动假定它是本地配置变量。为什么需要这个新选项?

【问题讨论】:

标签: git git-config


【解决方案1】:

由于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.

这个变化似乎首先出现在 2010 年底左右发布的 1.7.4 版本中。

据我快速查看源代码 (builtin/config.h) 和手册页可知,默认设置为本地除非设置了某些环境变量,尤其是 $GIT_CONFIG--local 选项显式覆盖任何环境变量设置。

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

【讨论】:

  • 正是我想要的!谢谢基思。
【解决方案2】:

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

Commit 560d4b86abc547dfb10b116ab99c800d68ae8849:

config:添加--local选项的描述

在一般描述中提到时,它在选项列表中被遗漏了。
添加它以确保完整性。

现在的描述是:

--local::
  • 对于写入选项:写入存储库.git/config 文件。
    这是默认行为。
  • 对于读取选项仅从存储库.git/config 而非所有可用文件中读取

【讨论】:

    猜你喜欢
    • 2021-12-06
    • 2010-11-03
    • 2011-03-28
    • 2016-11-02
    • 2017-07-19
    • 2021-11-30
    • 1970-01-01
    • 2020-01-20
    • 1970-01-01
    相关资源
    最近更新 更多