Fork me on GitHub

Mac安装Git

官网

https://git-scm.com/download/mac

brew安装git

brew install git

image

配置git

设置Git用户名和电子邮件:

#设置你的用户名
git config --global user.name "你的用户名"
#设置你的电子邮件地址
git config --global user.email "你的电子邮件地址"

#检查配置
git config --list

image

生成 SSH 密钥

#生成新的 SSH 密钥
ssh-keygen -t rsa -b 4096 -C "你的电子邮件地址"  

image

添加 SSH 密钥到 ssh-agent:

#启动 ssh-agent
eval "$(ssh-agent -s)"
#将 SSH 私钥添加到 ssh-agent
ssh-add -K ~/.ssh/id_rsa

image

将 SSH 密钥添加到 Git 服务器

#复制 SSH 公钥到剪贴板
pbcopy < ~/.ssh/id_rsa.pub

image

登录到Git 服务器账户,找到添加新 SSH 密钥的地方Settings/Developer Settings,粘贴并保存。
image
image

测试git命令连接github

ssh -T git@github.com

image

posted @ 2024-01-20 15:59  秋夜雨巷  阅读(18)  评论(0编辑  收藏  举报