原文: 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 or upstream 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

  1. Open Git Bash.

  2. Change the current working directory to your local project.

  3. 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)
  4. 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
    
  5. 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 fetchgit pull, or git push to the remote repository, you'll be asked for your GitHub username and password.

Switching remote URLs from HTTPS to SSH

  1. Open Git Bash.

  2. Change the current working directory to your local project.

  3. 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)
  4. 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
    
  5. 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的更多相关文章

  1. git 获取 remote 的 url

    git 获取 remote 的 url git ls-remote --get-url [remote] 例如: git ls-remote --get-url origin  

  2. 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 ...

  3. 修改Git远程地址 git config remote.origin.url "https://..."

    仓库管理: 添加或指定远程仓库地址 git remote set-url origin "https://..." git config remote.origin.url &qu ...

  4. git url ssh和https相互切换

    Changing a remote's URL The git remote set-url command changes an existing remote repository URL. Ti ...

  5. git配置ssh(github)

    [参考官方文档] SSH keys are a way to identify trusted computers, without involving passwords. The steps be ...

  6. Android ADT离线更新办法

    Troubleshooting ADT Installation If you are having trouble downloading the ADT plugin after followin ...

  7. NodeJS+Express+MySQL开发小记(2):服务器部署

    http://borninsummer.com/2015/06/17/notes-on-developing-nodejs-webapp/ NodeJS+Express+MySQL开发小记(1)里讲过 ...

  8. github push403错误的处理

    如果没有什么别的问题的话,推荐使用SSH的方式.请参考:http://stackoverflow.com/questions/7438313/pushing-to-git-returning-erro ...

  9. 【ASK】git使用中出现Permission denied (publickey).

    好久没有用git了,今天突然执行了一下 $git submodule update --init --recursive =============================== 结果出现如下提 ...

随机推荐

  1. java URL编程

    一.URL编程技术 URL是统一资源定位器的缩写,它是指向互联网“资源”的指针.URL表示了Internet上某个资源的地址.URL支持http,file,ftp等 多种协议.通过URL标识,可以直接 ...

  2. ios用xib实现三等分以及多等分思路

    Auto Layout 的本质原理 Auto Layout 的本质是用一些约束条件对元素进行约束,从而让他们显示在我们想让他们显示的地方. 约束主要分为以下几种(欢迎补充): 相对于父 view 的约 ...

  3. MFC实现登录对话框连接access数据库方式

    编写一个简单的登录对话框 大家好,我们利用MFC编写一个简单的登录对话框.主窗体是单文档界面.程序运行的时候,先弹出一个简单的登录对话框,输入用户名和密码后主窗体显示出来. 1.开打VC++6.0.点 ...

  4. Ubuntu基本命令--apt, dpkg

    一.Ubuntu中软件安装方法 1.APT方式 (1)普通安装:apt-get install softname1 softname2 …; (2)修复安装:apt-get -f install so ...

  5. 为什么要重写equals和hashCode

    1.重写equals方法时需要重写hashCode方法,主要是针对Map.Set等集合类型的使用: a: Map.Set等集合类型存放的对象必须是唯一的: b: 集合类判断两个对象是否相等,是先判断e ...

  6. hdu_3804_Query on a tree(树链剖分)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=3804 题意:给你一棵树,然后给出树上边的价值,然后给出x,y,问从1到x的边上不超过y的最大值为多少 ...

  7. html5结合flash实现视频文件在所有主流浏览器兼容播放

    来源:http://blog.csdn.net/freshlover/article/details/7535785/ 由于html5的出现,让网页中的视频.音频有了更加便捷的实现方式.但是video ...

  8. flash cs6 更新到Flash player15.0 及Air 更新方法

    1.自行下载Air 15.0 sdk (Flash player 包含在内) 2.  到15.0Air 包 里找player :AIR15.0\frameworks\libs\player 里面有pl ...

  9. caffe卷积输入通道如何到输出通道

    今天一个同学问 卷积过程好像是对 一个通道的图像进行卷积, 比如10个卷积核,得到10个feature map, 那么输入图像为RGB三个通道呢,输出就为 30个feature map 吗, 答案肯定 ...

  10. iwlist等工具的移植

    http://blog.csdn.net/jk110333/article/details/8658054 参考了这边文章 -------------------------------------- ...