1. 检查用户名和邮箱
# 查看用户名
git config user.name
# 查看邮箱
git config user.email
# 配置用户名
git config --global user.name "xxx"
# 配置邮箱
git config --global user.email "xxx"
2. 查看是否配置过SSH Key
ls ~/.ssh
# hyunmin@HyunmindeMacBook-Air .ssh % ls ~/.ssh
# id_rsa id_rsa.pub known_hosts
存在id_rsa id_rsa.pub文件即证明已配置过SSH Key
3. 生成SSH Key(秘钥)
ssh-keygen -t -rsa -C "email"
4. GitHub远程仓库添加公钥
-
复制
~/.ssh/id_rsa.pub
文件内容,并粘贴到GitHub->settings->SSH and GPG keys -
检查是否配置成功
ssh -T git@github.com
# 显示如下内容则表示配置成功
# Hi Ysfun! You've successfully authenticated, but GitHub does not provide shell access.
评论区