【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
相关推荐
摆烂z12 小时前
AI同时完成多个功能(Git WorkTree)
git
___波子 Pro Max.17 小时前
Git Worktree 可视化理解指南
git
61900833617 小时前
win wsl2 指定目录安装Ubuntu-24.04开启ssh sftp
linux·ubuntu·ssh
happymaker062618 小时前
git使用快速入门
git
MuzySuntree19 小时前
Ubuntu 使用 GitHub SSH 克隆时报 Permission denied (publickey) 解决方案
ubuntu·ssh·github
不做超级小白19 小时前
从零到可用:在手机上用 Termux + Git + Obsidian 打造稳定同步环境(踩坑全记录)
git·智能手机
凡客丶19 小时前
Git安装与使用保姆教程【超详细】
git
android_cai_niao19 小时前
给Git项目添加多个远程仓库
git·gitee·github
胡小禾19 小时前
多账号下git自动切号
git
zhensherlock19 小时前
Protocol Launcher 系列:Working Copy 提交与同步全攻略
javascript·git·typescript·node.js·自动化·github·js