Skip to content

环境变量配置

电脑 -> 属性 -> 高级系统设置 -> 环境变量 -> 系统变量 -> Path -> 编辑 -> 新建

C:\Program Files\Git\cmd

配置提交时显示的用户名和邮箱

sh
git config --global --list
git config --global user.name "xNoRain001"
git config --global user.email "3385842328@qq.com"

SSH Key

sh
ssh-keygen -t ed25519 -C "your_email@example.com"

Settings -> SSH and GPG Keys -> New SSH Key

Title 随意,Key 内容为 id_ed25519.pub 中的内容

同时支持 github 和 gitlab

sh
ssh-keygen -t ed25519 -C "your_gitlab_email@example.com" -f C:\Users\zmx\.ssh\id_ed25519_gitlab

不同仓库使用不同密钥

C:\Users\zmx.ssh 下添加 config 文件

Host github.com
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_ed25519

Host your_gitlab_email.example.com
  HostName your_gitlab_email.example.com
  User git
  IdentityFile ~/.ssh/id_ed25519_gitlab

gitlab

不要使用全局的 name 和 eamil,防止混淆,因此每个 gitlab 仓库中都需要重新配置

sh
git config --local --list
git config user.name "your_name"
git config user.email "your_gitlab_email@example.com"