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. ava中拦截器 过滤器 监听器都有什么区别

    过滤器,是在java web中,你传入的request,response提前过滤掉一些信息,或者提前设置一些参数,然后再传入servlet或者struts2的action进行业务逻辑,比如过滤掉非法u ...

  2. git merge简介【转】

    转自:http://blog.csdn.net/hudashi/article/details/7664382 git merge的基本用法为把一个分支或或某个commit的修改合并现在的分支上.我们 ...

  3. django-based blog- mezzanine

    django-based blog- mezzanine zinnia 博客 hydra  暴力破解

  4. Android模拟器使用教程

    Using the Emulator In this document Overview Android Virtual Devices and the Emulator Starting and S ...

  5. H5移动前端完美布局之-margin百分比的使用

    一 ,背景 在移动端页面开发我们经常会遇到一件尴尬的事 我们所开发出来的页面跟设计师所给的页面差别很大 再加上移动设备屏幕的大小不一出来的效果更是参差不齐 然后.... 当然 现实情况没有这么糟糕.. ...

  6. website project team member 角色及开发过程概念图

    一个web项目的团队往往具有以下角色的人员组成: project stakeholder(client or business owner)产品经理 Project manager 项目经理 prod ...

  7. xmlWriter 以UTF-8格式写xml问题

    dom4j中的XMLWriter提供以下几种构造方法: XMLWriter() XMLWriter(OutputFormat format) XMLWriter(OutputStream out) X ...

  8. 30个实用的Linux find命令

    除了在一个目录结构下查找文件这种基本的操作,你还可以用find命令实现一些实用的操作,使你的命令行之旅更加简易.本文将介绍15种无论是于新手还是老鸟都非常有用的Linux find命令 . 首先,在你 ...

  9. IOS中tableView每组的头部控件、通过tableView的代理方法控制某一行的cell能否达到高亮选中状态

    一.tableView每组的头部控件 1.控件宽度默认就是tableView的宽度 2.控件高度由下面的代理方法决定 - (CGFloat)tableView:(UITableView *)table ...

  10. Qt QGroupBox StyleSheet 边框设置

    /**************************************************************************** * Qt QGroupBox StyleSh ...