首页 > 技术文章 > 使用git远程连接GitHub仓库

ikventure 2021-08-10 15:49 原文

SSH 公钥

git bash运行ssh-keygen -t rsa,SSH会存储在以下名为id_rsa的pub文件中。

添加SSH

GitHub点击设置,找到SSH and GPG keys,将上述SSH公钥copy上去。

https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account

创建新仓库

  1. 先在GitHub页面Create a new repository,再在git bash执行git clone https://github.com/ikventure/cs61a-sp21将远程仓库克隆到本地。

  2. 或者直接在本地创建新文件夹,打开,然后执行git init

暂存 add

在项目文件夹中对文件进行增删改之后,运行git add.将所有改动暂存

提交 commit

git commit -m "commit information"将暂存的更改提交到本地仓库,并添加更改信息。

推送 push

git push origin main将更改推送到远程仓库。

出现errno 10054可尝试git push -u origin main进行验证,也可以尝试修改hosts。

提高git速度

https://www.ipaddress.com/ 查询github.com或github.global.ssl.fastly.net的IP添加到hosts文件中。

备注

码云操作同GitHub,可以考虑。

git部分配置可参考
https://www.cnblogs.com/ikventure/p/15024255.html

推荐阅读