【必须熟悉-- 实践 -- tortoiseGit -- settings】settings界面配置用法!以及配置文件具体文件位置!

0、【讲得简单明了】Git config 配置文件详解

一、配置文件级别

Git 使用简单的 .ini 文件作为配置文件,配置文件中记录了很多 Git 命令使用的各种选项和设置,Git 支持不同级别的配置文件,下面按照优先级从高到低的顺序对它们进行介绍:

.git/config           当前版本库特定的配置文件,可使用 --file选项修改,是Git的默认选项,
						此文件中的设置具有最高优先级。

~/.gitconfig         当前用户的配置文件,可使用 --global选项修改。

/etc/gitconfig      系统级别的配置文件,可使用 --system 选项修改,此文件中的设置优先级最低。

二、配置选项

git  config  --file  user.name  "sean"

git  config  --file  user.email  "[email protected]"

git  config  --global  user.name  "sean"

git  config  --global  user.email  "[email protected]"

git  config  --system  user.name  "sean"

git  config  --system  user.email  "[email protected]"

三、移除配置

使用 git config -l 命令可列出在配置文件中配置的所有项。

git config --unset 可移除配置文件中的配置,使用方法如下:

   git  config  --unset  user.name

   git  config  --unset  --global  user.name

   git  config  --unset  --system  user.name

1、中英文版 提示, 界面(tortioseTit – settings)

在这里插入图片描述在这里插入图片描述
在这里插入图片描述在这里插入图片描述
在这里插入图片描述
上图显示了 中英文版本的 打开提示,以及确认后配置的主界面的面板信息。。

优先级别:local(repo) > global(user)>system
配置文件路径(可以之总结界面点击):
1、仓库:projectPath/.git/config,(文件内容同 git config --local --list)
2、全局:C:\Users\10170364.gitconfig (文件内容同 git config --global --list)
3、系统【见3文章c】:C:\Program Files\Git\mingw64\etc (文件内容同 git config --system --list)【系统配置存在2个地方,见文章3!!】

2、git 修改配置

3、【讲得很详细】git config配置文件详解

(3).系统级别配置文件:

系统级别配置文件作用范围这是最广的,这个很好理解。

在很多教程上说,系统配置文件在git的安装目录下的etc目录中,然后真的在window系统的这个目录能找到吗。

截图如下:

其实并没有,实际在两个地方存储:

C:\ProgramData\Git\
C:\Program Files\Git\mingw64\etc

获取配置信息代码如下:

$ git config --system -l

system参数指定读取全局配置文件,l是list的缩写,当然也可以写成:

$ git config --system --list

特别说明:list的前面是两个中划线;如果参数是一个单词的缩写,前面一个中划线,如果是一个单词则两个。

读取文件截图如下:
在这里插入图片描述

上面读取的是C:\Program Files\Git\mingw64\etc目录下配置文件的内容。

读取所有配置文件计算后的最终结果可以使用如下代码:

$ git config -l

读取截图如下:
在这里插入图片描述

三.配置文件优先级:

配置文件的配置项有可能是重复的,优先级关系由大到小如下:

(1).当前项目级别。

(2).当前电脑用户级别。

(3).系统级别。

发布了350 篇原创文章 · 获赞 2 · 访问量 2110

猜你喜欢

转载自blog.csdn.net/m0_37681589/article/details/103710046