【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
相关推荐
csdn_aspnet3 小时前
Git灾难级误操作抢救手册:从reset到reflog的终极救援
git·恢复·误删
亚林瓜子4 小时前
linux账号强制密码过期导致私钥文件登录异常问题——(current) UNIX password:
linux·运维·服务器·ssh·aws·ec2·chage
2401_891655815 小时前
Git + 云原生:如何管理K8s配置版本?
git·云原生·kubernetes
m0_528174456 小时前
Git对象存储原理(blob/tree/commit) 引用日志(reflog)
大数据·git·elasticsearch·全文检索
无限进步_6 小时前
【C++】单词反转算法详解:原地操作与边界处理
java·开发语言·c++·git·算法·github·visual studio
pillowss7 小时前
SSH 登录服务器后 Backspace 失效?Ghostty + TERM 踩坑完整解决方案
服务器·ssh·github
Wzx1980129 小时前
Git分布式版本控制工具
git
不解不惑9 小时前
MacOS系统ssh和ftp,使用vscode实现
vscode·macos·ssh
whale fall21 小时前
git add、git commit、git push 的区别和联系
git
倾云鹤21 小时前
Git同时推送多个远程仓库
git