Git配置

配置用户信息

配置 Git 用户信息是使用 Git 的第一步,这有助于在提交记录中标识作者身份。

1
2
3
# 配置用户名和邮箱
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"

配置编码

为避免中文路径和文件名显示乱码,以及确保提交信息的编码正确,可以进行以下配置:

1
2
3
4
5
6
# 解决中文路径和文件名乱码问题
git config --global core.quotePath false

# 设置提交和日志输出的编码为 UTF-8
git config --global i18n.commitEncoding utf-8
git config --global i18n.logOutputEncoding utf-8

配置内网域名证书

当访问使用自签名证书的内网 Git 仓库时,需要配置 Git 信任该证书。

1
2
3
4
5
# 配置特定内网域名的 SSL 证书路径
git config --global http."内网域名".sslCAInfo "证书所在路径"

# 示例:配置 example.io 域名的自签名根证书
git config --global http."https://example.io".sslCAInfo ~/.certs/selfsigned-root-ca.crt