github clone
https
credentials
caching-your-github-credentials-in-git
ssh
一个 key 只能配置到一个 github 账户上
检查本地 ssh 秘钥
ls -alih ~/.ssh
创建 ssh 秘钥
ssh-keygen -t ed25519 -C "your_email@example.com"
# ssh-add 添加到 ssh-agent
ssh-add ~/.xxx.ed25519
编辑 ~.ssh/config
Host xxx
HostName github.com
IdentityFile ~/.ssh/id_rsa
User git
上传配置文件到 github
- 手动 copy paste 到 github 上
gh
cli .brew install gh
gh auth login # 选择 ssh key ,登录上之后即可自动上传对应的 keys
clone 代码
# origin url git@gitgithub.com:a/b.git
git clone host_xxx:a/b.git
# 如果过段时间报错没权限了,执行下 ssh-add ~/.xxx.rsa