Similar to the MySQL show variables
command that shows all variables and not just the ones defined in my.ini
, I would like to see a list of all config variables in git
along with their default values, and not just those defined in my ~/.gitconfig
.
Is this possible?
Update May 2018: git help -c
, as noted in Petr's answer.
With Git 2.19 (Q2 2018), continuing with the idea to programatically enumerate various pieces of data required for command line completion, teach the codebase to report the list of configuration variables subcommands care about to help complete them.
See commit f22f682 (27 May 2018), and commit 09c4ba4, commit bea2125, commit f45db83, commit e17ca92, commit 431bb23, commit fb6fbff, commit a4a9cc1, commit 3ac68a9, commit a46baac, commit fa151dc, commit a73b368 (26 May 2018) by Nguyễn Thái Ngọc Duy (pclouds
).
See commit 17b3e51 (29 May 2018) by Junio C Hamano (gitster
).
(Merged by Junio C Hamano -- gitster
-- in commit ebaf0a5, 25 Jun 2018)
help
: add--config
to list all available configSigned-off-by: Nguyễn Thái Ngọc Duy
Sometimes it helps to list all available config vars so the user can search for something they want. The config man page can also be used but it's harder to search if you want to focus on the variable name, for example.
This is not the best way to collect the available config since it's not precise. Ideally we should have a centralized list of config in C code (pretty much like 'struct option'), but that's a lot more work. This will do for now.
Original answer: 2015
That was debated in this thread in 2013, requested by Sebastian Schuberth, Jeff King (Peff
) adding:
The expected output is certainly a problem, but the issue is more fundamental than that:
git config
does not even know what the default is for any given option.It is assumed that the caller knows what to do with an unset value. And this is nothing to do with
git config
; the internal C code works the same way.
The actual defaults are not even necessarily expressible through the config.
E.g., I know thathttp.receivepack
considers "unset" to be distinct either "true
" or "false
", but setting it can yield only one of those latter two values.
I'm sure there are others, too (I just happened to notice that one this week).
I could certainly see an argument that the world would be a better place if the code had a big table of options and their descriptions, possible values, and defaults, and if we used that to generate documentation as well as validate input.
But nobody has gone to the trouble to construct that table and convert all of the callers. And as Jakub (Jakub Narębski) mentioned, such a central table can do nothing for external programs that store their config alongside git's.
In short:
git config
does not even know any of the options or values it manages, but just is a "dumb" front-end to writing / reading whatever you pass it to / from a file.
Note: git config was introduced in commit 1771299 (git 0.99.9a, Oct. 2005)
Different programs can react to different config options, although they should always fall back to calling "git_default_config()" on any config option name that they don't recognize.
So internally, there is a way to load default config, used as recently as commit 72549df, git 2.2.0-rc1, Nov. 2014, by the same Peff:
When we start the git-fetch program, we call git_config to load all config, but our callback only processes the
fetch.prune
option; we do not chain togit_default_config
at all.This means that we may not load some core configuration which will have an effect. For instance, we do not load
core.logAllRefUpdates
, which impacts whether or not we create reflogs in a bare repository.Let's just load the core config at the start of fetch, so we know we have it
See another example with commit 3e1dd17, git 1.7.7-rc1, Aug. 2011 with the default color config.