【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
相关推荐
岱宗夫up9 小时前
Git不是工具,是协作哲学
git
生活很暖很治愈10 小时前
Linux基础开发工具
linux·服务器·git·vim
极地星光11 小时前
如何使用 Git 实现 revert
git
厨 神11 小时前
IFLOW-Git-Claude
git·cloudera
ghostwritten17 小时前
git 发布版本
git
无限进步_19 小时前
206. 反转链表 - 题解与详细分析
c语言·开发语言·数据结构·git·链表·github·visual studio
是店小二呀19 小时前
Git远程仓库操作:从入门到精通的协作指南
git
令狐少侠201120 小时前
centos7 scp安全认证 ssh-keygen
android·安全·ssh
每天要多喝水20 小时前
git常用命令
git
哪里不会点哪里.21 小时前
Git 入门与常用操作总结
git