Skip to content

git 常用配置

配置用户信息

全局设置用户信息

sh
git config --global user.name "Your Username"
git config --global user.email "your.email@example.com"

局部设置

sh
git config user.name "Your Username"
git config user.email "your.email@example.com"

git 生成远程访问密钥对

生成自定义密钥对

sh
ssh-keygen -t rsa -C "your_email@example.com" -f ~/.ssh/id_rsa_custom

支持多个公钥

示例中,github-custom 是主机配置,您可以根据需要调整主机名和配置名称。IdentityFile 参数指定了私钥文件的路径。

conf
# ~/.ssh/config

Host github-custom.com    # 实际 ip or 域名
User git
IdentityFile ~/.ssh/id_rsa_custom

Site developed by Aomd.