类似于显示所有变量而不仅仅是show variables
中定义的变量的MySQL my.ini
命令,我希望在{{{}}中看到所有配置变量的列表{1}} 以及其默认值,而不仅仅是我git
中定义的值。
这可能吗?
答案 0 :(得分:24)
由in this thread in 2013 Sebastian Schuberth提出请求Jeff King (Peff
)进行了辩论,For instance: gc.prune
添加:
预期产量肯定是个问题,但问题更多 根本不是:
git config
甚至知道默认值 适用于任何给定的选项。假设调用者知道如何处理未设置的值。和 这与
git config
无关;内部C代码工作 同样的方式 实际默认值甚至不一定通过配置表示 例如,我知道http.receivepack
认为“未设置” 要区分“true
”或“false
”,但设置它只能产生 后两个值中的一个。
我也确定还有其他人(我本周碰巧注意到了这一点)。
我当然可以看到世界会变得更好的论点 如果代码有一个大的选项表和他们的描述,可能 值和默认值,如果我们使用它来生成文档 以及验证输入 但是没有人为构建该表并转换所有调用者而遇到麻烦。正如commit 1771299 (git 0.99.9a, Oct. 2005)提到的那样,这样的中央表对于将配置与git存储在一起的外部程序无效。
简而言之:
git config
甚至不知道它管理的任何选项或值, 但只是写作/阅读任何你通过的“愚蠢”的前端 它来自/来自文件。
注意:git配置是在commit 72549df, git 2.2.0-rc1, Nov. 2014
中引入的不同的程序可以对不同的配置选项做出反应,尽管它们可以 应该总是回到任何配置上调用“git_default_config()” 他们无法识别的选项名称。
所以在内部,有一种方法可以通过相同的Peff加载默认配置,最近用作commit 3e1dd17, git 1.7.7-rc1, Aug. 2011:
当我们启动git-fetch程序时,我们调用git_config来加载所有配置,但是我们的回调只处理
fetch.prune
选项;我们根本不会链接到git_default_config
。这意味着我们可能无法加载一些会产生影响的核心配置。例如,我们不加载
core.logAllRefUpdates
,这会影响我们是否在裸存储库中创建reflog。让我们在fetch的开头加载核心配置,所以我们知道我们有它
答案 1 :(得分:18)
git config --global -l
表示全局变量,git config -l
表示本地存储库变量
答案 2 :(得分:4)
如果您具有git 2.19或更高版本
git help -c
将列出所有可用于配置的已知密钥
答案 3 :(得分:3)
此方法不会为您提供您的设置以及默认值,但这是获取记录的设置(以及记录的默认值)的可靠方法):
首先从源存储库获取文档
svn export https://github.com/git/git/trunk/Documentation
,或者如果您没有svn
,
curl -L https://api.github.com/repos/git/git/tarball/master | tar -xvzf- --strip-components=1 --wildcards --no-anchored 'Documentation/*'
输入目录
cd Documentation
开始grep
。我有两个版本:一个详细,一个更紧凑(可能缺少详细信息)。为了(部分)清晰起见,我将在下面使用较长的标志名称。
首先是精简版:
grep --initial-tab \
--recursive \
--binary-files=without-match \
--no-filename \
--only-matching \
--perl-regexp \
--null-data \
--regexp='(?ms)(?:^[a-z][a-zA-Z]+\.[<>()*.a-zA-Z]+::\v+)+?(?:(?:\v|\h+\V+\v))+(?:\v|\Z)'
对于更“详细”的版本,只需将--regexp=
标志更改为
(?ms)(?:^[a-z][a-zA-Z]+\.[<>()*.a-zA-Z]+::\v+)+?(?:(?:\v|\h+\V+\v))+(?:\+\v+(?:--\v+.+?--|[^+]\V+(?!::\v))+)*(?:\v|\Z)
展开的是
(?ms)
(?:
^[a-z][a-zA-Z]+\.
[<>()*.a-zA-Z]+::\v+
)+?
(?:
(?:\v|\h+\V+\v)
)+
(?:
\+\v+
(?:
--\v+
.+?
--
|
[^+]\V+(?!::\v)
)+
)*
(?:\v|\Z)
由于这都是基于正则表达式提取的,所以不用说这有一天可能会中断(如果他们更改了txt
文件的文档格式)。
一些示例输出-请注意,并非所有人都具有默认值:
core.hideDotFiles::
(Windows-only) If true, mark newly-created directories and files whose
name starts with a dot as hidden. If 'dotGitOnly', only the `.git/`
directory is hidden, but no other files starting with a dot. The
default mode is 'dotGitOnly'.
core.precomposeUnicode::
This option is only used by Mac OS implementation of Git.
When core.precomposeUnicode=true, Git reverts the unicode decomposition
of filenames done by Mac OS. This is useful when sharing a repository
between Mac OS and Linux or Windows.
(Git for Windows 1.7.10 or higher is needed, or Git under cygwin 1.7).
When false, file names are handled fully transparent by Git,
which is backward compatible with older versions of Git.
core.protectHFS::
If set to true, do not allow checkout of paths that would
be considered equivalent to `.git` on an HFS+ filesystem.
Defaults to `true` on Mac OS, and `false` elsewhere.
core.protectNTFS::
If set to true, do not allow checkout of paths that would
cause problems with the NTFS filesystem, e.g. conflict with
8.3 "short" names.
Defaults to `true` on Windows, and `false` elsewhere.
core.fsmonitor::
If set, the value of this variable is used as a command which
will identify all files that may have changed since the
requested date/time. This information is used to speed up git by
avoiding unnecessary processing of files that have not changed.
See the "fsmonitor-watchman" section of linkgit:githooks[5].
core.trustctime::
If false, the ctime differences between the index and the
working tree are ignored; useful when the inode change time
is regularly modified by something outside Git (file system
crawlers and some backup systems).
See linkgit:git-update-index[1]. True by default.
core.splitIndex::
If true, the split-index feature of the index will be used.
See linkgit:git-update-index[1]. False by default.
core.untrackedCache::
Determines what to do about the untracked cache feature of the
index. It will be kept, if this variable is unset or set to
`keep`. It will automatically be added if set to `true`. And
it will automatically be removed, if set to `false`. Before
setting it to `true`, you should check that mtime is working
properly on your system.
See linkgit:git-update-index[1]. `keep` by default.
core.quotePath::
Commands that output paths (e.g. 'ls-files', 'diff'), will
quote "unusual" characters in the pathname by enclosing the
pathname in double-quotes and escaping those characters with
backslashes in the same way C escapes control characters (e.g.
`\t` for TAB, `\n` for LF, `\\` for backslash) or bytes with
values larger than 0x80 (e.g. octal `\302\265` for "micro" in
UTF-8). If this variable is set to false, bytes higher than
0x80 are not considered "unusual" any more. Double-quotes,
backslash and control characters are always escaped regardless
of the setting of this variable. A simple space character is
not considered "unusual". Many commands can output pathnames
completely verbatim using the `-z` option. The default value
is true.