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. 利用SOLR搭建企业搜索平台 之——运行solr

    来源:http://blog.csdn.net/zx13525079024/article/details/24806131 本节主要介绍Solr的安装,其实Solr不需要安装.直接下载就可以了    ...

  2. linux环境变量(转)

    转自: http://www.cnblogs.com/growup/archive/2011/07/02/2096142.html Linux 的变量可分为两类:环境变量和本地变量 环境变量 或者称为 ...

  3. 了解ThinkPHP(一)

    1.项目开发,中,会遇到的问题: 1). 多人开发项目,分工不合理,(html   php   mysql) 2). 代码风格不一样,后期维护十分困难 3). 项目生命周期十分短,项目生命没有延续性, ...

  4. MySQL 字段常用操作 添加,修改,删除,调整字段顺序

    整理备忘: 添加字段:alter table 表名Add column 字段名 字段类型  默认值 AFTER 字段名 (在哪个字段后面添加) 例子: alter table appstore_sou ...

  5. Ubuntu 安装vsftp软件(已测试)

    首先开启Ftp端口 使用apt-get命令安装vsftp #apt-get install vsftpd -y 添加ftp帐号和目录 先检查一下nologin的位置,通常在/usr/sbin/nolo ...

  6. 安装cloudera

    1. 查看selinux状态 $ /usr/sbin/getenforce Enforcing $ /usr/sbin/sestatus SELinux status: enabled SELinux ...

  7. Z-偏移量

    使用Z-偏移量 在一个三维场景中,我们可以对共面的多边形使用z-偏移量来使它们不再共面.这项技术通常用于在场景中正确的显示阴影.例如,一堵墙上的阴影与这堵墙的深度值是相同的,如果我们先渲染了墙再来渲染 ...

  8. 维护没有源代码,float改成double

    float f= 931340.31f; Console.WriteLine(f.ToString("#,###,##0.00")); 返回 931,340.30 ,float 1 ...

  9. tomcat启动出错(转)

    刚刚装载好的myeclipse 在添加项目到服务器的时候,突然异常涌现. 其实这是一个新手常见的错误.平常配置JDK环境的时候有些人习惯把JDK安装到磁盘的当前文件夹里,这样十分的方便,但是安装时,你 ...

  10. notebook笔记

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