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 =============================== 结果出现如下提 ...
随机推荐
- js或jquery实现图片轮播
如: 1.//3个div的统一class = 'div' var index =0; //3秒轮播一次 var timer = setInterval(function(){ index = ...
- CodeForces 753C Interactive Bulls and Cows (Hard)
题意:... 析:随机判断就即可,每次把不正确的删除,经过几次后就基本剩不下了. 代码如下: #pragma comment(linker, "/STACK:1024000000,10240 ...
- Chapter 2 Open Book——19
He bent over and began scraping together a pile of the white mush. 他弯下腰,开始团起一个白色的雪球. "I'll see ...
- Broken Keyboard(悲剧文本)
你有一个键盘,键盘上所有的键都能正常使用,只是Home键和End键有时会自动按下.你并不知道这一情况,而是专心地打稿子,甚至连显示器都没开电源.当你打开显示器之后,展现在你面前的是一段悲剧文本.你的任 ...
- AngularJs多重视图和路由的使用
使用AngularJs来做多重视图和路由是在方便不过了,在开发过程中,都有许多的页面,而这些页面都有相同的部分,比如页面的头部和尾部通常都是一样的,变化的都是主体部分,还有就是一些后端管理的一些项目, ...
- Vim常用命令【转载】
下面基本是vim的基本用法,刚开始学习可能有些不习惯.但贵在坚持,即使不习惯,也要坚持使用,做到不经过思考就能操作,你会发现真的很方便.很多操作可以通过不同的命令达到,我这里只列出常用的. 基础命令 ...
- JavaConcurrentHashMap
JavaConcurrentHashMap 大滕翼不自觉地往前探了探身子可还没等他听到唐寅说到 兆咒耶Т √靼脶摹 す宿坩曹 '字'心'上都有横您老瞧瞧这个'宣德 炔灌莞 蹇忄в 幼銮亿辽 仄黛境 ...
- ASP.NET获取客户端信息,获取客户端IP等等
山上明月 ASP.NET能知道的东西 获取服务器电脑名: Page.Server.ManchineName 获取用户信息: Page.User 获取客户端电脑名:Page.Request.UserHo ...
- 让您的Xcode键字如飞
手指在键盘上飞速跳跃,终端上的代码也随着飞舞,是的这确实很酷.优秀的程序员总是这么一群人,他们不拘于现状,不固步自封,他们喜欢新奇的事,他们把自己发挥到极致. 指法攻略 放下您钟爱的鼠标吧,在前行之中 ...
- 【jsp】读取WebRoot下的图像文件
package readPic; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream ...