Tools frequently need to change their behavior based on values stored in
Git’s configuration files. These files may have complicated conditions
for including extra files, so it is difficult to produce an independent
parser. To avoid executing multiple processes to discover or modify
multiple configuration values, the git config-batch command allows a
single process to handle multiple requests using a machine-parseable
interface across stdin and stdout.
By default, the protocol uses line feeds (LF) to signal the end of a
command over stdin or a response over stdout.
The protocol will be extended in the future, and consumers should be
resilient to older Git versions not understanding the latest command
set. Thus, if the Git version includes the git config-batch builtin
but doesn’t understand an input command, it will return a single line
response:
unknown_command LF
These are the commands that are currently understood:
helpversion 1-
The
helpcommand lists the currently-available commands in this version of Git. The output is multi-line, but the first line provides the count of possible commands viahelp count <N>. The next<N>lines are of the formhelp <command> <version>to state that this Git version supports that<command>at version<version>. Note that the same command may have multiple available versions.Here is the currentl output of the help text at the latest version:
help 1 count 2 help 1 help 1 help 1 get 1
getversion 1-
The
getcommand searches the config key-value pairs within a given<scope>for values that match the fixed<key>and filters the resulting value based on an optional<value-filter>. This can either be a regex or a fixed value. The command format is one of the following formats:get 1 <scope> <key> get 1 <scope> <key> arg:regex <value-pattern> get 1 <scope> <key> arg:fixed-value <value>
The
<scope>value can be one ofinherited,system,global,local,worktree,submodule, orcommand. Ifinherited, then all config key-value pairs will be considered regardless of scope. Otherwise, only the given scope will be considered.If no optional arguments are given, then the value will not be filtered by any pattern matching. If
arg:regexis specified, then the rest of the line is considered a single string,<value-pattern>, and is interpreted as a regular expression for matching against stored values, similar to specifying a value toget config --get <key> "<value-pattern>". Ifarg:fixed-valueis specified, then the rest of the line is considered a single string,<value>, and is checked for an exact match against the key-value pairs, simmilar togit config --get <key> --fixed-value "<value>".At mmost one key-value pair is returned, that being the last key-value pair in the standard config order by scope and sequence within each scope.
If a key-value pair is found, then the following output is given:
get 1 found <key> <scope> <value>
If no matching key-value pair is found, then the following output is given:
get 1 missing <key> [<value-pattern>|<value>]
where
<value-pattern>or<value>is only supplied if provided in the command.