【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 [email protected]: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
相关推荐
李菠菜12 分钟前
解决Windows系统下Git克隆时报错“unable to checkout working tree”的方法详解
windows·git
island131420 分钟前
【git#4】分支管理 -- 知识补充
大数据·git·elasticsearch
船长@Quant2 小时前
协作开发攻略:Git全面使用指南 — 引言
git·版本控制·源代码管理·协作开发
极小狐3 小时前
极狐GitLab 项目功能和权限解读
运维·git·安全·gitlab·极狐gitlab
宁酱醇3 小时前
GitLab_密钥生成(SSH-key)
运维·ssh·gitlab
极小狐3 小时前
极狐GitLab 如何 cherry-pick 变更?
人工智能·git·机器学习·gitlab
GnixAij5 小时前
Docker SSH端口转发
docker·ssh
前端太佬6 小时前
从拧螺丝到造火箭:Git高阶玩家生存报告
前端·git·github
前端太佬6 小时前
从青铜到塑料:Git逃难指南(附救命指令大全)
前端·git·github
Athel6 小时前
git 建立本地仓库并且推送到github上
git