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时需要先链接远程仓库

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

相关推荐
我有一棵树5 小时前
一、GitHub 的 WIP 功能简介
github·开发·前端、
想用offer打牌7 小时前
如何开启第一次开源贡献之路?
java·后端·面试·开源·github
week_泽11 小时前
PicGo图床搭载Github,上传博客图片
github
CoderJia程序员甲14 小时前
GitHub 热榜项目 - 日榜(2025-12-26)
开源·大模型·llm·github·ai教程
星际编程喵15 小时前
研发流程规范:Git Commit 书写标准
git·gitee·github·gitcode
阿里嘎多学长17 小时前
2025-12-25 GitHub 热点项目精选
开发语言·程序员·github·代码托管
郑同学zxc18 小时前
AI 代码助手:CodeGeex、RooCode 和 GitHub Copilot 对比
github·copilot
CoderJia程序员甲1 天前
GitHub 热榜项目 - 日榜(2025-12-24)
ai·开源·llm·github
逛逛GitHub2 天前
国产AI大模型 Minimax M2.1效果相当惊艳,赶紧试试
github
-拟墨画扇-2 天前
Git | 文件提交操作
git·gitee·github·gitcode