【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
相关推荐
Unity粉末状在校生4 小时前
Git解决fatal: Could not read from remote repository.的问题
git
少年攻城狮4 小时前
Obsidian系列---【如何使用obsidian同步到git?】
git
do better myself7 小时前
网站源码如何部署和加入GIT仓库的
git
爱学英语的程序员9 小时前
Git 提交 LF will be replaced by CRLF the next time Git touches it 报错
git
qq_3391911410 小时前
服务器git pull每次都要输入密码,linux 设置git登录,linux设置git只输入一次账户密码
git
一颗小行星!16 小时前
快速理解 Git submodule
git
Zhu75818 小时前
【软件更新】在Ubuntu24 LTS中更新openssl到指定版本,例如openssl3.5.6 LTS
linux·ssh·ssl
有理想的打工人18 小时前
gitlab群组管理与ssh链接
ssh·gitlab
A-Jie-Y18 小时前
Git基础-核心概念与常用命令
git
夜珀19 小时前
Git基础修炼手册:在AtomGit上玩转版本控制
git