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
  • A new URL for the remote, for example:
    • https://github.com/USERNAME/REPOSITORY_2.git if you're updating to use HTTPS
    • git@github.com:USER/REPOSITORY_2.git if you're updating to use SSH

Switching remote URLs from SSH to HTTPS

  1. Open Terminal (for Mac and Linux users) or the command line (for Windows users).
  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 remote set-url command.

    $ git remote set-url origin https://github.com/USERNAME/REPOSITORY_2.git
    
  5. Verify that the remote URL has changed.

    $ git remote -v
    # Verify new remote URL
    # origin https://github.com/USERNAME/REPOSITORY2.git (fetch)
    # origin https://github.com/USERNAME/REPOSITORY2.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 Terminal (for Mac and Linux users) or the command line (for Windows users).
  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 remote set-url command.

    git remote set-url origin git@github.com:USERNAME/REPOSITORY2.git
    
  5. Verify that the remote URL has changed.

    $ git remote -v
    # Verify new remote URL
    # origin git@github.com:USERNAME/REPOSITORY2.git (fetch)
    # origin git@github.com:USERNAME/REPOSITORY2.git (push)

git url ssh和https相互切换的更多相关文章

  1. TortoiseGit的ssh key和Git的ssh key

    情景模拟: 你使用Git+TortoiseGit对项目进行版本控制,本地库(自己电脑建立的.git)与远程库(如GitLab上建立)通信需要使用ssh验证,你用git生成公钥并保存到了Gitlab上, ...

  2. Git设置ssh密钥

    前提条件是,公司的gitlab,运维没有关闭ssh的权限获取,或者叫运维开通那个ssh权限,生成的公钥要给运维那边一个!这样设置是可以成功 一.创建ssh key 1.在客户端查看有没有密钥 cd ~ ...

  3. git使用ssh密钥和https两种认证方式汇总(转)

    在版本库的SSH方式和HTTPS方式是不同的,具体来说就是url信息的不同,但是,实际的认证机制也是不同的.当建立了本机密钥之后,使用ssh方式实际上是不需要再次认证的,而https则每次需要输入密码 ...

  4. Mac下git通过SSH进行免密码安全连接github

    Git——The stupid content tracker(傻瓜内容跟踪器) Git是Linux的缔造者Linus Torvalds为了帮助管理Linux内核源码而开发的一款免费.开源的分布式版本 ...

  5. Git配置SSH Key

    最近看到很多人在配置Git时,遇到很问题,网上教程千篇一律.这儿自己单独记录一份. Git配置SSH Key 1.检查本机是否有ssh key设置,切换到.ssh目录 $ cd ~/.ssh 或cd ...

  6. 网络数据传输安全及SSH与HTTPS工作原理

    本节内容 网络数据传输安全概述 数据加密算法分类 SSH工作原理 HTTPS工作原理 参考资料 个人一直在努力推动git在公司内部的普及和使用,前些日子在公司内部做了一次分享课,给大家介绍了下项目发布 ...

  7. git 使用ssh密钥

    一.查看仓库支持的传输协议 1.1查看仓库支持的传输协议 使用命令 git remote -v 查看你当前的 remote url root@zengyue:/home/yuanGit# git re ...

  8. Git 使用SSH密钥操作

    git使用ssh密钥 git支持https和git两种传输协议,github分享链接时会有两种协议可选: git协议链接图例 : ↓ https协议链接图例:↓ git使用https协议,每次pull ...

  9. Git 仓库 SSH、HTTP、Gitweb (Nginx) 乱炖

    简介: 自己搭建 Git 仓库,实现 SSH 协议.配合 Nginx 实现 HTTP 协议拉取.推送代码. 利用 Nginx 实现 Gitweb 在线浏览代码,使用 Gitweb-theme 更新默认 ...

随机推荐

  1. Volley HTTP库系列教程(2)Volley.newRequestQueue示例,发请求的流程,取消请求

    Sending a Simple Request Previous  Next This lesson teaches you to Add the INTERNET Permission Use n ...

  2. php注册登录系统(一)-极简

    序 登录注册系统是日常上网最普通的操作,我设了一个分类一步步完善注册登录系统,若有哪里错误请慧教 所用语言:php 数据库 :mysql 本次实现功能: 1.用户注册 2.用户登录 主要文件: 完整代 ...

  3. Java关键字static、final

    static  1. static变量     按照是否静态的对类成员变量进行分类可分两种:一种是被static修饰的变量,叫静态变量或类变量:另一种是没有被static修饰的变量,叫实例变量.两者的 ...

  4. 函数mem_pool_create

    /********************************************************************//** Creates a memory pool. @re ...

  5. 四、Emmet:快速编写HTML,CSS代码的有力工具

    介绍 Emmet是一个插件,在IDE中安装该插件后即可使用该功能. HTML代码写起来虽简单,但是重复代码很多,Emmet能够存在一种HTML代码简写法(比较类似CSS的选择器写法),比如 div.c ...

  6. HDU 3573 Buy Sticks (逻辑)

    题意:a,b,c三种棍子长度分别为20,28,32,现需要这三种棍子数根,欲买长为75的棍子来剪成这三种(不够长的就废弃) ,问需要买多少根. 思路:将所有棍子尽可能和其他搭配起来,使得数量减到最少. ...

  7. notebook笔记

    启动 __main__.py 静态文件 static/ 模板 templates/ 路由 比如tree/handlers.py default_handlers WebSocket ws://loca ...

  8. Linux Shell编程(5):整数运算

    http://blog.sina.com.cn/s/blog_6db275da0101asmf.html #!/bin/sh let a=$1+$2 b=$[$1+$2] ((c=$1+$2)) d= ...

  9. 【英语】Bingo口语笔记(35) - 常见单词结尾发音

  10. Heritrix源码分析(九) Heritrix的二次抓取以及如何让Heritrix抓取你不想抓取的URL

    本博客属原创文章,欢迎转载!转载请务必注明出处:http://guoyunsky.iteye.com/blog/644396       本博客已迁移到本人独立博客: http://www.yun5u ...