Changing a remote's URL
原文: https://help.github.com/articles/changing-a-remote-s-url/
Changing a remote's URL
- MAC
- WINDOWS
- LINUX
The git remote set-url
command changes an existing remote repository URL.
Tip: For information on the difference between HTTPS and SSH URLs, see "Which remote URL should I use?"
The git remote set-url
command takes two arguments:
- An existing remote name. For example,
origin
orupstream
are two common choices. A new URL for the remote. For example:
If you're updating to use HTTPS, your URL might look like:
https://github.com/USERNAME/OTHERREPOSITORY.git
If you're updating to use SSH, your URL might look like:
git@github.com:USERNAME/OTHERREPOSITORY.git
Switching remote URLs from SSH to HTTPS
Open Git Bash.
Change the current working directory to your local project.
List your existing remotes in order to get the name of the remote you want to change.
git remote -v origin git@github.com:USERNAME/REPOSITORY.git (fetch) origin git@github.com:USERNAME/REPOSITORY.git (push)
Change your remote's URL from SSH to HTTPS with the
git remote set-url
command.git remote set-url origin https://github.com/USERNAME/OTHERREPOSITORY.git
Verify that the remote URL has changed.
git remote -v # Verify new remote URL origin https://github.com/USERNAME/OTHERREPOSITORY.git (fetch) origin https://github.com/USERNAME/OTHERREPOSITORY.git (push)
The next time you git fetch
, git pull
, or git push
to the remote repository, you'll be asked for your GitHub username and password.
- If you have two-factor authentication enabled, you must create a personal access token to use instead of your GitHub password.
- You can use a credential helper so Git will remember your GitHub username and password every time it talks to GitHub.
Switching remote URLs from HTTPS to SSH
Open Git Bash.
Change the current working directory to your local project.
List your existing remotes in order to get the name of the remote you want to change.
git remote -v origin https://github.com/USERNAME/REPOSITORY.git (fetch) origin https://github.com/USERNAME/REPOSITORY.git (push)
Change your remote's URL from HTTPS to SSH with the
git remote set-url
command.git remote set-url origin git@github.com:USERNAME/OTHERREPOSITORY.git
Verify that the remote URL has changed.
git remote -v # Verify new remote URL origin git@github.com:USERNAME/OTHERREPOSITORY.git (fetch) origin git@github.com:USERNAME/OTHERREPOSITORY.git (push)
Troubleshooting
You may encounter these errors when trying to changing a remote.
No such remote '[name]'
This error means that the remote you tried to change doesn't exist:
git remote set-url sofake https://github.com/octocat/Spoon-Knife fatal: No such remote 'sofake'
Check that you've correctly typed the remote name.
Further reading
转载于:https://www.cnblogs.com/oxspirt/p/6063507.html
Changing a remote's URL相关推荐
- git服务器 修改url,如何更改Git Remote的URL
Git Remote是一个指针,它指向通常托管在远程服务器上的存储库的另一个副本. 在某些情况下,例如将远程存储库迁移到另一个主机时,您需要更改远程URL. 本指南介绍了如何更改Git遥控器的URL. ...
- 为Eclipse安装安卓开发插件ADT
ADT下载地址:http://dl.google.com/android/ADT-20.0.3.zip 有关ADT的介绍及安装环境要求:http://developer.android.com/too ...
- 解决fatal: No remote repository specified. Please, specify either a URL...
今天在电脑上用Git pull命令来更新本地项目,突然发现出现如标题的错误: [plain] view plaincopyprint? user ~/c/quhao$git pull fatal: N ...
- linux篡改url命令,在Linux中更改Git远程URL(Git Remote URL)的方法
本文说明了如何更改Git远程的URL,在Linux平台中已测试成功.Git remote是一个指针,它指向通常托管在远程服务器上的存储库的另一个副本,在某些情况下,例如当远程存储库迁移到另一个主机时, ...
- git remote添加其他SSH端口
本文翻译自:git remote add with other SSH port 在Git中,当主机使用不同的SSH端口时,如何添加远程源服务器? git remote add origin ssh: ...
- 如何更改远程Git存储库的URI(URL)?
我在硬盘驱动器(本地)上克隆的USB密钥上有一个回购(来源). 我将"起源"移至NAS并成功测试了从此处克隆它的过程. 我想知道是否可以在"本地"设置中更改&q ...
- 如何确定最初克隆本地Git存储库的URL?
几天前我从GitHub上撤了一个项目. 我已经发现GitHub上有几个叉子,我忽略了我最初采用的那个. 如何确定我拉出的哪个叉子? #1楼 打印任意命名的远程提取URL: git remote -v ...
- 解决github push错误The requested URL returned error: 403 Forbidden while accessing(转)
github push错误: git push error: The requested URL returned error: 403 Forbidden while accessing https ...
- fatal: unable to access : The requested URL returned error: 403
错误提示如下 C:\Users\AllenIverson\Desktop\gitbook-test>git push -u gitbook master remote: Forbidden fa ...
最新文章
- python重复元素判定编程_从零开始学Python编程四:条件判断与循环
- Eclipse启动出现“Failed to create the Java Virtual Machine”错误
- python实现并发http_python 2.7 如何实现http post多并发?
- lucene 入门整理
- Activiti中的安全脚本如何工作
- 重磅!“东方理工大学”来了!
- uwsgi怎么通过浏览器访问某个脚本_4个Shell小技巧帮你提高机器学习效率:写好脚本,事半功倍...
- 122 - Trees on the level(模拟内存池解法)
- linux系列之-—01 shell编程笔记
- IDEA + Spring boot devtools 热部署 与 多实例启动
- 经典而常用的配乐和背景音乐合集(下)
- 我很高兴,很欣慰:)
- 诗词乱拼 zz from smth.org
- vue项目使用iconfont(本地下载、彩色icon)
- Excel下拉菜单如何制作?
- 开水果蔬菜超市利润大吗?
- 面试.net资深程序员的前5分钟
- IDEA2016 license server 激活
- 计算机中全半角转换是干什么的,全角半角切换快捷键(电脑全角和半角怎么切换)...
- 没有躲过的坑--有if就要有else(一定成对)
热门文章
- 谷歌Chrome浏览器开发者工具教程—基础功能篇
- 数值分析matlab实验报告,数值分析第一次作业matlab实验报告.doc
- mysql教程日志_MySQL日志
- python数据可视化第三方库有哪些_数据可视化!看看程序员大佬都推荐的几大Python库...
- 目标检测(十七)--PVANet
- .net 本地文件管理 代码_Gitee 在线解决代码冲突上线,解决冲突不再需要 Git 命令...
- 适配器模式的原理与实现
- sbt命令行常用命令
- clickhouse入门与安装
- Hbase数据模型入门