git-study-md/git02.md

70 lines
1.3 KiB
Markdown

## git config 配置
- 安全和隐私
- 设置指令别名,提高工作效率
- 设置默认选项
### 1. 查看当前 `config` 配置
```
git config --list
```
![](git02_files/1.jpg)
### 2. 用户名 & 邮箱配置
#### 2.1 为什么要单独配置?
<font size="2">&emsp;&emsp;
为了防止工作用户&邮箱和个人用户&邮箱混淆,防止信息泄露。
</font>
#### 2.2 三种级别说明
- system 级别
- global 级别
- local 级别
<font size="2">&emsp;&emsp;
git 读取时:优先从 local > global > system 级别
</font>
#### 2.3 全局 & 局部配置
> 系统级配置 `--system`
<font size="2">&emsp;&emsp;
系统用户级的配置,一般不用。
</font>
> 全局设置 `--global`
```
git config --global user.name '***'
git config --global user.email '***@**.com'
```
> 局部设置 `--local`
<font size="2">&emsp;&emsp;
不写默认是局部
</font>
```
git config user.name '***'
git config user.email '***@**.com'
```
![](git02_files/2.jpg)
### 3. `alias` 别名全局配置
#### 3.1 常用指令别名配置
```
git config --global alias.st status
git config --global alias.pl pull
git config --global alias.ps push
```
#### 3.2 操作截图
![](git02_files/3.jpg)
### 4. 默认选项配置
```
git config --global pull.rebase true
```