article/git/git多环境配置.md
2023-07-03 16:34:34 +08:00

60 lines
864 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## git 多环境配置
### 多密钥配置
编辑 ~/.ssh/config 配置文件
```
# gitee
Host gitee.com
HostName gitee.com
Port 22
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_gitee #平台私钥地址
# github
Host github.com
HostName github.com
Port 22
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_github #平台私钥地址
#低版本 加密兼容
Host *
HostkeyAlgorithms +ssh-dss,ssh-rsa
PubkeyAcceptedKeyTypes +ssh-dss,ssh-rsa
```
### 提交用户配置
每个平台建立一个目录 该平台下的所有项目 放在该目录下
d:\work
在全局配置文件 `~/.gitconfig` 末尾追加配置
```
[includeIf "gitdir/i:d:/work/"]
path = ~/.gitconfig_work
```
在用户目录 `~` 新建 文件 `.gitconfig_work`
内容如下
```
[user]
email = xxxx@yilingairdata.com
name = xxxx
```