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 =============================== 结果出现如下提 ...
随机推荐
- hdu_1115_Lifting the Stone(求多边形重心)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1115 题意:给你N个点围成的一个多边形,让你求这个多边形的重心. 题解: 将多边形划分为若干个三角形. ...
- SQL SERVER 2000 遍历父子关系数据的表(二叉树)获得所有子节点 所有父节点及节点层数函数
---SQL SERVER 2000 遍历父子关系數據表(二叉树)获得所有子节点 所有父节点及节点层数函数---Geovin Du 涂聚文--建立測試環境Create Table GeovinDu([ ...
- PHP的几个常用加密函数【转载】
转自 https://jellybool.com/post/php-encrypt-functions 在网站的开发过程中,常常需要对部分数据(如用户密码)进行加密,本文主要介绍PHP的几个常见的加密 ...
- Memcached 缓存服务器介绍
1.memcached 高性能分布式内存对象缓存系统 2.目的:减轻数据库负载,提高基于动态数据库驱动网站的响应速度 3.数据格式:文本行 4.协议:memcache协议 5.存储方式:hashMa ...
- VS2010中安装AjaxControlToolkit
原文地址:http://www.asp.net/ajaxlibrary/act.ashx 第一步 下载Ajax Control Toolkit 进入网址http://ajaxcontroltoolki ...
- wpf之数据触发器DataTrigger
wpf, 根据绑定的属性的值的不同(数据分类),界面上显示不同的控件(绑定不同类型的属性),可以使用数据库触发器DataTrigger实现这一功能. 实现的效果如下: 首先建立实体类: 更改通知类: ...
- JS动态引入js、CSS动态创建script/link/style标签
一.动态创建link方式 我们可以使用link的方式.如下代码所示. function addCssByLink(url){ var doc=document; var link=doc.create ...
- 如何使用Android中的OpenGL ES媒体效果
引自:http://www.2cto.com/kf/201506/404366.html Android的媒体效果框架允许开发者可以很容易的应用多种令人印象深刻的视觉效果到照片或视频之上.作为这个媒体 ...
- CodeForces 566B Replicating Processes
#include <bits/stdc++.h> #define N 3010 #define LL long long #define unsigned U using namespac ...
- Login 和 Logout
inux下Login和Logout详解 Login 是你用Linux系统工作时面对的第一个进程,这对于使用终端以及通过网络使用Linux都是正确的.但是login进程本身 ...