Changing a remote's URL
原文: https://help.github.com/articles/changing-a-remote-s-url/
Changing a remote's URL
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
Changing a remote's URL的更多相关文章
- git 获取 remote 的 url
git 获取 remote 的 url git ls-remote --get-url [remote] 例如: git ls-remote --get-url origin
- Command failed: git -c core.longpaths=true config --get remote.origin.url
「Unable to Connect to GitHub.com For Cloning」 Error: Command failed: git -c core.longpaths=true conf ...
- 修改Git远程地址 git config remote.origin.url "https://..."
仓库管理: 添加或指定远程仓库地址 git remote set-url origin "https://..." git config remote.origin.url &qu ...
- git url ssh和https相互切换
Changing a remote's URL The git remote set-url command changes an existing remote repository URL. Ti ...
- git配置ssh(github)
[参考官方文档] SSH keys are a way to identify trusted computers, without involving passwords. The steps be ...
- Android ADT离线更新办法
Troubleshooting ADT Installation If you are having trouble downloading the ADT plugin after followin ...
- NodeJS+Express+MySQL开发小记(2):服务器部署
http://borninsummer.com/2015/06/17/notes-on-developing-nodejs-webapp/ NodeJS+Express+MySQL开发小记(1)里讲过 ...
- github push403错误的处理
如果没有什么别的问题的话,推荐使用SSH的方式.请参考:http://stackoverflow.com/questions/7438313/pushing-to-git-returning-erro ...
- 【ASK】git使用中出现Permission denied (publickey).
好久没有用git了,今天突然执行了一下 $git submodule update --init --recursive =============================== 结果出现如下提 ...
随机推荐
- poll机制分析[转]
所有的系统调用,基于都可以在它的名字前加上"sys_"前缀,这就是它在内核中对应的函数.比如系统调用open.read.write.poll,与之对应的内核函数为:sys_open ...
- JedisConnectionException: Unexpected end of stream.
在实际项目中遇到redis读取时报错. 报错是 [ERROR] redis.clients.jedis.exceptions.JedisConnectionException: Unexpected ...
- leetcode83,删除有序链表中的重复元素
Given a sorted linked list, delete all duplicates such that each element appear only once. For examp ...
- Java编程中时区和时间相关的问题
先说一个结论:时间戳是一个和时区无关的东西,在哪里都是一致的!但是转化为字符串之后,就和时区有关系了. 以下为内容: 参考链接:http://m.blog.csdn.net/article/detai ...
- eclipse4.3 安装tomcat8
Go to the WTP downloads page, select the 3.6.0 version , and download the zip (under Traditional Zip ...
- HDU1236:排名
Problem Description 今天的上机考试虽然有实时的Ranklist,但上面的排名只是根据完成的题数排序,没有考虑 每题的分值,所以并不是最后的排名.给定录取分数线,请你写程序找出最后 ...
- js纯ajax
var XMLHttpReq; function createXMLHttpRequest() { try { XMLHttpReq = new ActiveXObject("Msxml2. ...
- C# 将字符串转为ऩ这种的 html实体编码
1.字符串转为html实体编码 private string GetHtmlEntities(string str) { string r = string.Empty; ; i < str.L ...
- drupal7 分页
$output = ""; $query = db_select('feedback','f')->extend('PagerDefault');//->extend( ...
- 错误 1 error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏 C:\Users\Administ
错误 1 error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏 C:\Users\Administ 这两个fatal error是因为从低版本的WTL到高版本的WTL转变后产生的 ...