【Git】已经在拉取时以HTTP的URL拉取的仓库使用SSH的URL进行push

添加remote url即可。

添加前:

bash 复制代码
➜  Linux-for-Newbies git:(main) git remote -v
origin  https://github.com/ZhaoCake/Linux-for-Newbies.git (fetch)
origin  https://github.com/ZhaoCake/Linux-for-Newbies.git (push)

添加:

bash 复制代码
git remote add --mirror=push ssh_one git@github.com:ZhaoCake/Linux-for-Newbies.git

添加后:

bash 复制代码
➜  Linux-for-Newbies git:(main) git push ssh_one
The authenticity of host 'github.com (20.205.243.166)' can't be established.
ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])?yyes
Warning: Permanently added 'github.com' (ED25519) to the list of known hosts.
Enumerating objects: 6, done.
Counting objects: 100% (6/6), done.
Delta compression using up to 8 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (5/5), 2.88 KiB | 46.00 KiB/s, done.
Total 5 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
To github.com:ZhaoCake/Linux-for-Newbies.git
   1b13d37..3833b61  main -> main
 * [new reference]   origin/HEAD -> origin/HEAD
 * [new reference]   origin/main -> origin/main

如何生成SSH公钥,资料很多,不必分享。

复制代码
ssh-keygen -t rsa
相关推荐
MrLi010440 分钟前
在git中同时配置gitcode和github访问权限
git·github·gitcode
越来越无动于衷40 分钟前
Git 团队协作完全指南:从基础到高级应用
git
小怪兽会微笑1 小时前
如何上传github(解决git的时候输入正确的账号密码,但提示认证失败)
git·github
Komorebi_999913 小时前
Git常用指令
git·web
一小池勺16 小时前
🚀 Git 如何让文件存在于远程仓库却不被本地追踪?
git·github
五月高高18 小时前
Idea使用git不提示账号密码登录,而是输入token问题解决
git
魏 无羡18 小时前
idea实现git版本回退的常见场景
java·git·intellij-idea
ergevv21 小时前
不同场景下git指令的搭配
git·源代码管理·代码
不了_谢谢1 天前
项目仓库文件太大怎么清理?如何清理git仓库大文件记录?
git