【git命令】config

名称
git-config - 获取并设置仓库或者全局选项

概要

git config [<file-option>] [--type=<type>] [--fixed-value] [--show-origin] [--show-scope] [-z|--null] <name> [<value> [<value-pattern>]]
git config [<file-option>] [--type=<type>] --add <name> <value>
git config [<file-option>] [--type=<type>] [--fixed-value] --replace-all <name> <value> [<value-pattern>]
git config [<file-option>] [--type=<type>] [--show-origin] [--show-scope] [-z|--null] [--fixed-value] --get <name> [<value-pattern>]
git config [<file-option>] [--type=<type>] [--show-origin] [--show-scope] [-z|--null] [--fixed-value] --get-all <name> [<value-pattern>]
git config [<file-option>] [--type=<type>] [--show-origin] [--show-scope] [-z|--null] [--fixed-value] [--name-only] --get-regexp <name-regex> [<value-pattern>]
git config [<file-option>] [--type=<type>] [-z|--null] --get-urlmatch <name> <URL>
git config [<file-option>] [--fixed-value] --unset <name> [<value-pattern>]
git config [<file-option>] [--fixed-value] --unset-all <name> [<value-pattern>]
git config [<file-option>] --rename-section <old-name> <new-name>
git config [<file-option>] --remove-section <name>
git config [<file-option>] [--show-origin] [--show-scope] [-z|--null] [--name-only] -l | --list
git config [<file-option>] --get-color <name> [<default>]
git config [<file-option>] --get-colorbool <name> [<stdout-is-tty>]
git config [<file-option>] -e | --edit

选项
-replace-all
默认行为是最多替换一行。这将替换与键匹配的所有行(以及可选的值模式)。

--add
在不更改任何现有值的情况下向选项添加新行。这与在–replace all中提供^$作为值模式相同。

--get
获取给定键的值(可选地由匹配该值的正则表达式过滤)。 如果未找到键,则返回错误代码 1;如果找到多个键值,则返回最后一个值。
Get the value for a given key (optionally filtered by a regex matching the value). Returns error code 1 if the key was not found and the last value if multiple key values were found.

--get-all
与 get 类似,但返回多值键的所有值。

--get-regexp
与–get-all 类似,但将名称作为正则表达式并写出键的名称。

--get-urlmatch <name> <URL>
当给出一个由两部分组成的名称section.key时,返回section..key最匹配的给定的部分。

--global
对于写入选项:写入到全局~/.gitconfig 文件而不是仓库,如果 $XDG_CONFIG_HOME/git/config文件存在且 ~/.gitconfig 文件不存在,则写入该文件。

--system
对于写入选项:写入系统范围的 $(prefix)/etc/gitconfig 而不是存储库 .git/config。
对于读取选项:仅从系统范围的 $(prefix)/etc/gitconfig 而不是从所有可用文件中读取。

--local
对于写入选项:写入存储库 .git/config 文件。 这是默认行为。
对于读取选项:仅从存储库 .git/config 中读取,而不是从所有可用文件中读取。

--worktree
与 --local 类似, 如果启用 extensions.worktreeConfig 则除了 $GIT_DIR/config.worktree被读取或写入。

-f <config-file>
--file <config-file>
对于写入选项:写到指定文件而不是仓库的.git/config
对于读取选项:仅从指定文件而不是从所有可用文件中读取。

--blob <blob>
类似于 --file 但使用给定的 blob 而不是文件

--remove-section
从配置文件中删除给定的部分。

--rename-section
将给定部分重命名为新名称。

--unset
从配置文件中删除与键匹配的行。

--unset-all
从配置文件中删除与键匹配的所有行。
Remove all lines matching the key from config file.

-l
--list
列出配置文件中设置的所有变量及其值。

--fixed-value
与 value-pattern 参数一起使用时,将 value-pattern 视为精确字符串而不是正则表达式。

--type <type>
git config 将确保任何输入或输出在给定的类型约束下都是有效的,并将规范化 规范形式的传出值。

--bool
--int
--bool-or-int
--path
--expiry-date
用于选择类型说明符的历史选项。

--no-type
取消设置之前设置的类型说明符。

-z
--null
对于输出值和/或键的所有选项,始终以空字符(而不是换行符)结束值。 使用换行符作为键和值之间的分隔符。

--name-only
仅输出 --list 或 --get-regexp 的配置变量的名称。

--show-origin
使用源类型(文件、标准输入、blob、命令行)和实际源(配置文件路径、ref 或 blob id,如果适用)增加所有查询配置选项的输出。

--show-scope
与–show origin类似,它使用该值的范围(本地、全局、系统、命令)来增加所有查询的配置选项的输出。

--get-colorbool <name> [<stdout-is-tty>]
找到 的颜色设置(例如 color.diff)并输出“true”或“false”。

--get-color <name> [<default>]
找到为 name 配置的颜色(例如 color.diff.new)并将其作为 ANSI 颜色转义序列输出到标准输出

-e
--edit
打开编辑器修改指定的配置文件; --system、–global 或repository(默认)。
Opens an editor to modify the specified config file; either --system, --global, or repository (default).

--[no-]includes
在查找值时遵从配置文件中的 include.* 指令。

--default <value>
当使用 --get 并且未找到请求的变量时, 表现是分配给该变量的值。

⚠️ 此git命令基于2.36.0版本

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值