参考资料
- 优快云:赤砂之蝎我爱罗(git生成并添加SSH key)
- Sheldon Xu(执行ssh-add时出现Could not open a connection to your authentication agent)
- 孙氏楼(第一次使用Git上传本地项目到github上)
写在前面
配置
Git 信息配置
配置用户信息
- $
git config --global user.name "XXX" - $
git config --global user.email "XXX@XXX.com"
SSH 信息配置
生成SSH密钥 最后得到了两个文件:id_rsa和id_rsa.pub(默认路径,默认名称(不指定文件路径))
cd ~/.ssh/【如果没有对应的文件夹,则执行 mkdir ./.ssh】ssh-keygen -t rsa -C "XXX@XXX.com"ssh-add id_rsa添加密钥到SSHssh-agent bash首次执行ssh-add id_rsa时出现Could not open a connection to your authentication agent 需要先执行该命令cat id_rsa.pub复制文本内容到GitHub 上添加SSH密钥(添加公钥)- 测试
ssh git@github.com
GitHub SSH 信息配置
添加公钥 我的-> setting -> SSH and GPG keys -> New SSH key -> 添加公钥到[Key] 中

2.
![添加公钥到[Key] 中](https://i-blog.csdnimg.cn/blog_migrate/c14425c0116f54e510324982e328915c.png)
创建
本地仓库配置
git init创建本地仓库- 添加文件
git status查看文件状态 git add.将本地文件暂存本地仓库git commit -m ":XXX"将缓存文件刷新到本地仓库
创建远程仓库
repository ->New repository 创建一个远程库 -> 新建 README.md 文件
本地链接远程
新建的远程仓库是空的,所以要加上
-u这个参数,等远程仓库里面有了内容之后,下次再从本地库上传内容的时候只需下面这样就可以了:$ git push origin master
git remote add origin https://github.com/XXX.git|git remote add origin git@github.com:XXX.git添加远程仓库$ git pull --rebase origin HEAD拉取远程库$ git push -u origin master本地库数据推送到远程库
1522

被折叠的 条评论
为什么被折叠?



