【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
相关推荐
研究是为了理解5 小时前
Git Bash 常用命令
git·elasticsearch·bash
DKPT5 小时前
Git 的基本概念和使用方式
git
Winston Wood8 小时前
一文了解git TAG
git·版本控制
喵喵先森9 小时前
Git 的基本概念和使用方式
git·源代码管理
xianwu54310 小时前
反向代理模块
linux·开发语言·网络·git
Amelio_Ming10 小时前
Permissions 0755 for ‘/etc/ssh/ssh_host_rsa_key‘ are too open.问题解决
linux·运维·ssh
binishuaio12 小时前
Java 第11天 (git版本控制器基础用法)
java·开发语言·git
会发光的猪。13 小时前
如何在vscode中安装git详细新手教程
前端·ide·git·vscode
stewie615 小时前
在IDEA中使用Git
java·git
晓理紫1 天前
使用git lfs向huggingface提交较大的数据或者权重
git