github本地仓库push到远程仓库

1.从远程仓库clone到本地

2.生成SSH秘钥,为push做准备

在Ubuntu命令行输入一下内容

bash 复制代码
[root@localhost ~]# ssh-keygen -t rsa       <== 建立密钥对,-t代表类型,有RSA和DSA两种
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):   <==密钥文件默认存放位置,按Enter即可
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):     <== 输入密钥锁码,或直接按 Enter 留空
Enter same passphrase again:     <== 再输入一遍密钥锁码
Your identification has been saved in /root/.ssh/id_rsa.    <== 生成的私钥
Your public key has been saved in /root/.ssh/id_rsa.pub.    <== 生成的公钥
The key fingerprint is:
SHA256:K1qy928tkk1FUuzQtlZK+poeS67vIgPvHw9lQ+KNuZ4 root@localhost.localdomain
The key's randomart image is:
+---[RSA 2048]----+
|           +.    |
|          o * .  |
|        . .O +   |
|       . *. *    |
|        S =+     |
|    .    =...    |
|    .oo =+o+     |
|     ==o+B*o.    |
|    oo.=EXO.     |
+----[SHA256]-----+

最后生产SSH Key的秘钥对, id_rsa 是私钥,不能泄露出去, id_rsa.pub 是公钥,可以放心地告诉任何人。

按这个目录去.ssh目录下找到id_rsa.pub这个文件夹打开复制全部内容。

在github上面添加公钥将上面内容复制到下图位置

输入ssh -T git@github.com,查看SSH公钥密钥是否配置成功,出现下面信息表明成功

3.将更新了的本地仓库push到远程仓库

第一次push时需要先链接远程仓库

后面提交只要输入下面四句命令即可

相关推荐
wflynn13 小时前
GitHub 日榜趋势速报 | 2026-10-10
开源·github
fthux14 小时前
开源小工具 Who Arrives:看看你的公网 IP、地区、时区和网络
http·开源·github
来自于狂人14 小时前
GitHub 开源趋势日报 | 2026年10月10日,告别 Mermaid 的图表设计系统
开源·github
u13013014 小时前
GitHub 热榜项目:日榜(2026-10-10)
人工智能·github
Python测试之道16 小时前
GitHub 实战课|Playwright MCP:让 AI 真的会用浏览器
人工智能·github
小陈运维16 小时前
GitHub Actions + Docker + ACR + GHCR 自动化构建与发布
github
miofly17 小时前
AI 智能体用 83% 字节精确匹配反编译完整游戏
开源·github
TunerT_TQ20 小时前
开源评测】openai/math 深度拆解:722 份 AI 数学手稿与 Lean 形式化的工程真相
github
W.A委员会20 小时前
PID自动整定与LLM调优项目使用说明(源码附文末)
自动化·github