【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
相关推荐
深海鱼在掘金19 小时前
Git 完全指南 —— 第1章:Git 概览与版本控制演进
git
开发者联盟league1 天前
安装pnpm
ssh
noravinsc2 天前
关于Git Flow
git
2601_961875242 天前
决战申论100题2026|最新|范文
linux·容器·centos·debian·ssh·fabric·vagrant
蜜獾云2 天前
在Git中配置用户名和密码
git
scx_link2 天前
通过git bash在本地创建分支,并推送到远程仓库中
开发语言·git·bash
南大白2 天前
IntelliJ IDEA 运行时的 JVM 本地内存溢出崩溃
git
码农小旋风2 天前
Claude Code 基础用法大全:对话、分析、修改、测试、Git 和工作流
人工智能·git·chatgpt·claude
南大白2 天前
Git 撤回提交完整方案
git
像风一样的男人@2 天前
python --实现代理服务器
git·ui