类似于MySQL的show variables
命令,显示中定义的所有变量,而不仅仅是那些my.ini
,我想看到的清单全部在配置变量git
连同它们的默认值,而不仅仅是那些在我的定义~/.gitconfig
.
这可能吗?
Von*_*onC 26
这是讨论在此线程在2013年,被要求塞巴斯蒂安Schuberth,杰夫·金(Peff
)补充说:
预期的输出肯定是一个问题,但问题比这更基本:
git config
甚至不知道任何给定选项的默认值.假设调用者知道如何处理未设置的值.这与此毫无关系
git config
; 内部C代码以相同的方式工作.
在实际的默认值甚至不需要通过配置表达.
例如,我知道http.receivepack
认为"未设置"与"true
"或"false
"不同,但设置它只能产生后两个值中的一个.
我也确定还有其他人(我本周碰巧注意到了一个).
如果代码有大量的选项及其描述,可能的值和默认值,并且如果我们使用它来生成文档以及验证输入,我当然可以看到一个论点,即世界会更好.
但是没有人为构建该表并转换所有调用者而遇到麻烦.正如Jakub(JakubNarębski)所提到的,这样的中央表对于将配置与git存储在一起的外部程序无能为力.
简而言之:
git config
甚至不知道它管理的任何选项或值,但只是一个"愚蠢"的前端来写/读任何你传入/从文件传递它.
注意:git config在commit 1771299中引入(git 0.99.9a,2005年10月)
不同的程序可以对不同的配置选项做出反应,尽管它们应该总是回到在他们无法识别的任何配置选项名称上调用"git_default_config()".
因此在内部,有一种方法可以加载默认配置,最近使用提交72549df,git 2.2.0-rc1,2014年11月,由同一个Peff:
当我们启动git-fetch程序时,我们调用git_config来加载所有配置,但我们的回调只处理该
fetch.prune
选项; 我们根本没有链接git_default_config
.这意味着我们可能无法加载一些会产生影响的核心配置.例如,我们不加载
core.logAllRefUpdates
,这会影响我们是否在裸存储库中创建reflog.我们只是在fetch的开头加载核心配置,所以我们知道我们拥有它
请参阅另一个使用默认颜色配置的提交3e1dd17,git 1.7.7-rc1,2011年8月的示例.
Mat*_*eil 23
git config --global -l
全局变量或git config -l
本地存储库变量
PS:我知道自你发布问题已经过去了2年,但我一直在寻找同样的事情,我读了这篇文章所以我猜想像我这样的用户会想要解决他们的问题而且我发了回复,即使你可能很久以前就解决了你的问题.
此方法不会为您提供您的设置以及默认值,但这是获取记录设置(以及它们的默认值,如果记录)的非常可靠的方法:
首先从源代码库获取文档
svn export https://github.com/git/git/trunk/Documentation
Run Code Online (Sandbox Code Playgroud)
或者如果你没有svn
,
curl -L https://api.github.com/repos/git/git/tarball/master | tar -xvzf- --wildcards "*/Documentation/*"
Run Code Online (Sandbox Code Playgroud)
进入目录
cd Documentation
Run Code Online (Sandbox Code Playgroud)
现在我们grep
。我有 2 个版本:一个详细的,一个更紧凑的(可能缺少细节)。为了(某些)清晰起见,下面使用了长标志名称。
首先是精简版:
grep --recursive \
--binary-files=without-match \
--no-filename \
--only-matching \
--perl-regexp \
--null-data \
--regexp='(?ms)(?:^[a-zA-Z0-9]{2,}\.[<>()*.a-zA-Z -]+::\v+)+?(?:(?:\v|\h+\V+\v))+(?:\v|\Z)'
Run Code Online (Sandbox Code Playgroud)
对于更“详细”的版本,只需将--regexp=
标志更改为
(?ms)(?:^[a-zA-Z0-9]{2,}\.[<>()*.a-zA-Z -]+::\v+)+?(?:\v|\h+\V+\v)+(?:\+\v+(?:--\v+.+?--|[^+]\V+(?!::\v))+)*(?:\v|\Z)
Run Code Online (Sandbox Code Playgroud)
并且由于这完全基于正则表达式提取,因此不言而喻,这可能有一天会中断(例如,如果他们更改配置文档格式以使其不依赖于asciidoctor
)。
一些示例输出——请注意,并非所有输出都有默认值:
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.
Run Code Online (Sandbox Code Playgroud)
注意事项:
versionsort.prereleaseSuffix
和add.ignore-errors
不是目标,可能不会被选中。grep --recursive --binary-files=without-match --only-matching --perl-regexp --regexp='^([^-'"'"'</[ ]+\.|\t+)[a-zA-Z0-9-<>_\*]+(?=::$)'
Run Code Online (Sandbox Code Playgroud)
但是,在这种情况下可能会出现误报。 归档时间: |
|
查看次数: |
36756 次 |
最近记录: |