Mac下创建Github的ssh Key并往github上发布新项目
1、创建SSH Key文件
ssh-keygen -t ed25519 -C "zhangfanxp@hotmail.com"
2、命令行复制SSH公钥
pbcopy < ~/.ssh/id_ed25519.pub
3、浏览器登录github
4、进入SSH and GPG keys页面
5、添加新的SSH Key
6、填写SSH Key的相关内容
Title 不支持空格,单词之间用_连接;
Key type 使用默认的Authentication Key即可;
Key 部分要用pbcopy < ~/.ssh/id_ed25519.pub命令拷贝的内容黏贴。
7、添加Add SSH Key
8、查看gh的登录状态
gh auth status
如果展示:Logged in to github.com account zhangfanxp 则说明gh已成功登录。
如果gh没有安装,请使用brew install gh命令安装gh
9、设置Git自动使用gh登录的Github身份进行认证
gh auth setup-git
10、运行代码上传操作
git init
git remote add origin. https://github.com/zhangfanxp/test01.git
git add .
git commit -m "Initial commit"
git branch -M main
export https_proxy=http://127.0.0.1:7890
export http_proxy=http://127.0.0.1:7890
git push -u origin main
评论
发表评论