When did git introduce the “--local” switch for git config command?

笑着哭i 提交于 2019-12-05 20:45:55

问题


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?


回答1:


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).




回答2:


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.


来源:https://stackoverflow.com/questions/9632794/when-did-git-introduce-the-local-switch-for-git-config-command

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!