show variables
命令类似,它显示所有变量而不仅仅是在my.ini
中定义的变量,我想要看到 git
中所有配置变量列表及其默认值,而不仅仅是在我的 ~/.gitconfig
中定义的变量。是否可能?show variables
命令类似,它显示所有变量而不仅仅是在my.ini
中定义的变量,我想要看到 git
中所有配置变量列表及其默认值,而不仅仅是在我的 ~/.gitconfig
中定义的变量。是否可能?git config --system -l
获取系统范围内的变量(从安装文件夹中检索; 参考文献)
git config --global -l
获取全局变量(从~/.gitconfig
或$XDG_CONFIG_HOME/git/config
(如果第一个不存在)的位置进行检索; 参考文献)
对于存储库变量,使用git config --local -l
或git config -l
进行检索(从.git/config
中检索; 参考文献)
请注意,尽管文档上说
--local
[...] 这是默认行为。
但发出 git config -l --local
命令显示的结果与 git config -l
不同,后者(显然)显示了所有三个命令的输出合并后的结果(在 Windows 上进行测试)。
git config --global -l
获取全局变量或 git config -l
获取本地存储库变量
P.S .:我知道您发布问题已经过去了2年,但我正在寻找同样的东西,并阅读了这篇文章,所以我猜想像我这样的用户会希望解决他们的问题,因此我发表了回复,即使您可能很久以前已经解决了问题。
git help -c
命令。pclouds
)完成。gitster
)完成。gitster
--合并于commit ebaf0a5,2018年6月25日)
help
:添加--config
以列出所有可用的配置签名:Nguyễn Thái Ngọc Duy
有时候列出所有可用的配置变量可以帮助用户查找他们想要的内容。也可以使用配置手册,但如果您想专注于变量名称进行搜索,则会更加困难。
这不是收集可用配置的最佳方式,因为它不够精确。理想情况下,我们应该在C代码中拥有一个集中的配置列表(类似于“struct option”),但这需要更多的工作。暂时先这样吧。
PhilipOakley
)。gitster
--合并于提交 68658a8,2021年9月23日)
doc
:配置,告诉读者如何使用git help --config
签名:Philip Oakley
git config
现在在其手册页面中包含以下内容:
可以使用
git help --config
命令获取所有可用的配置变量列表。
原始答案:2015
这在2013年的这个帖子中进行了讨论,由Sebastian Schuberth提出请求,Jeff King(Peff
)补充说:
git config
甚至不知道它管理的任何选项或值,只是一个“愚蠢”的前端,用于将您传递给它的内容写入/读取文件。
git help -c
"(man)来帮助命令行自动完成配置变量。avar
)。gitster
--合并于提交 62f035a,2021年10月13日)
帮助/完成
:让"git help"来做艰苦的工作签名:Ævar Arnfjörð Bjarmason
"help"内置命令自e17ca92(“completion
: drop the hard coded list of config vars”,2018-05-26,Git v2.19.0-rc0 -- merge listed in batch #1)以来就能够输出配置变量,但它的输出格式并不完全符合补全脚本的要求。
我们来解决这个问题。completion
: use 'sort -u' to deduplicate config variable names”,2019-08-13,Git v2.24.0-rc0 -- merge listed in batch #3)和d943887(“completion
: deduplicate configuration sections”,2019-08-13,Git v2.24.0-rc0 -- merge listed in batch #3)中,我们已经完成了部分工作,但在这之后仍然需要对列表进行排序、去重和awk后处理。string_list_remove_duplicates()
,这样调用者就不需要再调用“sort -u
”了。
经过“sort -u
”处理后,“--config-for-completion”输出与之前相同。--config-for-completion
输出中的“alias.”)的配置节。git-completion.bash
的shell中运行。
例如,如果我们更改了选项名称,他们会看到关于git-completion.bash无法找到“--config-for-completion”选项的消息。git-completion.bash
尚未缓存旧的“--config-for-completion”输出。git cmd -h
学会了通过列出可否定的选项来表示这些选项,例如 --[no-]opt
。rscharfe
)完成。gitster
--合并于提交 6d159f5, 2023年8月25日)
parse-options
:在简短的帮助信息中显示选项的否定性
Signed-off-by: René Scharfe
Add a "
[no-]
" prefix to options without the flagPARSE_OPT_NONEG
to document the fact that you can negate them.This looks a bit strange for options that already start with "no-", e.g. for the git option
--no-name
of show-branch:
--[no-]no-name suppress naming strings
You can actually use
--no-no-name
as an alias of--name
, so the short help is not wrong.
If we strip off any of the "no-"s, we lose either the ability to see if the remaining one belongs to the documented variant or to see if it can be negated.
git rev-parse
现在在其手册页中包含了:
--[no-]foo some nifty option --foo --[no-]bar ... some cool option --bar with an argument --[no-]baz <arg> another cool option --baz with a named argument --[no-]qux[=<path>] qux may take a path argument but has meaning by itself
git config
只存在于读取配置文件,而不知道任何关于 git 设置的信息。 - VonC如果您拥有 Git 2.19 或更新版本
git help -c
列出所有已知可用于配置的键
git help --config
。 - Freedom_Ben这种方法不能获取你的设置和默认设置,但这是一种获得记录的设置(如果有文档)的非常可靠的方法:
首先从源代码库中获取文档。
svn export https://github.com/git/git/trunk/Documentation
如果您没有 svn
,
curl -L https://api.github.com/repos/git/git/tarball/master | tar -xvzf- --wildcards "*/Documentation/*"
进入目录
cd Documentation
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)'
如果需要更详细的版本,只需将--regexp=
标志更改为
(?ms)(?:^[a-zA-Z0-9]{2,}\.[<>()*.a-zA-Z -]+::\v+)+?(?:\v|\h+\V+\v)+(?:\+\v+(?:--\v+.+?--|[^+]\V+(?!::\v))+)*(?:\v|\Z)
由于这全部基于正则表达式提取,所以不用说,如果他们改变配置文档格式使其不再依赖于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.
注意事项:
versionsort.prereleaseSuffix
and add.ignore-errors
are not targeted and will probably not be picked up.grep --recursive --binary-files=without-match --only-matching --perl-regexp --regexp='^([^-'"'"'</[ ]+\.|\t+)[a-zA-Z0-9-<>_\*]+(?=::$)'
There will probably be false positives in this case, however.brew install grep
,然后将上述 grep
替换为 ggrep
。 另外,为了更清晰--您将使用 cat <documentation_file_of_interest>.txt | ggrep <crazy_grep_command>
。 - Luke Davisgit help config
也提供了文档。 - user202729
git config --list
不是 Harry 寻找的,因为它只会返回在系统、全局或本地级别明确设置的配置,而不是所有其他未设置的设置及其默认值。 - VonC