git url ssh和https相互切换
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 HTTPSgit@github.com:USER/REPOSITORY_2.git
if you're updating to use SSH
Switching remote URLs from SSH to HTTPS
- Open Terminal (for Mac and Linux users) or the command line (for Windows users).
- 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
remote set-url
command.$ git remote set-url origin https://github.com/USERNAME/REPOSITORY_2.git
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 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 Terminal (for Mac and Linux users) or the command line (for Windows users).
- 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
remote set-url
command.git remote set-url origin git@github.com:USERNAME/REPOSITORY2.git
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相互切换的更多相关文章
- TortoiseGit的ssh key和Git的ssh key
情景模拟: 你使用Git+TortoiseGit对项目进行版本控制,本地库(自己电脑建立的.git)与远程库(如GitLab上建立)通信需要使用ssh验证,你用git生成公钥并保存到了Gitlab上, ...
- Git设置ssh密钥
前提条件是,公司的gitlab,运维没有关闭ssh的权限获取,或者叫运维开通那个ssh权限,生成的公钥要给运维那边一个!这样设置是可以成功 一.创建ssh key 1.在客户端查看有没有密钥 cd ~ ...
- git使用ssh密钥和https两种认证方式汇总(转)
在版本库的SSH方式和HTTPS方式是不同的,具体来说就是url信息的不同,但是,实际的认证机制也是不同的.当建立了本机密钥之后,使用ssh方式实际上是不需要再次认证的,而https则每次需要输入密码 ...
- Mac下git通过SSH进行免密码安全连接github
Git——The stupid content tracker(傻瓜内容跟踪器) Git是Linux的缔造者Linus Torvalds为了帮助管理Linux内核源码而开发的一款免费.开源的分布式版本 ...
- Git配置SSH Key
最近看到很多人在配置Git时,遇到很问题,网上教程千篇一律.这儿自己单独记录一份. Git配置SSH Key 1.检查本机是否有ssh key设置,切换到.ssh目录 $ cd ~/.ssh 或cd ...
- 网络数据传输安全及SSH与HTTPS工作原理
本节内容 网络数据传输安全概述 数据加密算法分类 SSH工作原理 HTTPS工作原理 参考资料 个人一直在努力推动git在公司内部的普及和使用,前些日子在公司内部做了一次分享课,给大家介绍了下项目发布 ...
- git 使用ssh密钥
一.查看仓库支持的传输协议 1.1查看仓库支持的传输协议 使用命令 git remote -v 查看你当前的 remote url root@zengyue:/home/yuanGit# git re ...
- Git 使用SSH密钥操作
git使用ssh密钥 git支持https和git两种传输协议,github分享链接时会有两种协议可选: git协议链接图例 : ↓ https协议链接图例:↓ git使用https协议,每次pull ...
- Git 仓库 SSH、HTTP、Gitweb (Nginx) 乱炖
简介: 自己搭建 Git 仓库,实现 SSH 协议.配合 Nginx 实现 HTTP 协议拉取.推送代码. 利用 Nginx 实现 Gitweb 在线浏览代码,使用 Gitweb-theme 更新默认 ...
随机推荐
- (九)ASP.NET自定义用户控件(2)
http://www.cnblogs.com/SkySoot/archive/2012/09/04/2670678.html 用户控件 在 .NET 里,可以通过两种方式把自己的控件插入到 Web 窗 ...
- hdu - 1240 Nightmare && hdu - 1253 胜利大逃亡(bfs)
http://acm.hdu.edu.cn/showproblem.php?pid=1240 开始没仔细看题,看懂了发现就是一个裸的bfs,注意坐标是三维的,然后每次可以扩展出6个方向. 第一维代表在 ...
- Android HTTPS(3) IOException: Hostname 解决方案
Common Problems with Hostname Verification As mentioned at the beginning of this article, there are ...
- VS2015中添加新建项,找不到ado .net entity datamodel的解决方法
http://stackoverflow.com/questions/23046081/missing-ado-net-entity-data-model-on-visual-studio-2013 ...
- 戏(细)说Executor框架线程池任务执行全过程(上)
一.前言 1.5后引入的Executor框架的最大优点是把任务的提交和执行解耦.要执行任务的人只需把Task描述清楚,然后提交即可.这个Task是怎么被执行的,被谁执行的,什么时候执行的,提交的人就不 ...
- php设计模式之观察者模式
观察者模式:能够更便利地创建查看目标对象状态的对象,并且提供与核心对象非耦合的指定功能性. 利用这种模式可以方便地创建一个对象(观察者),其可以用来“监视”另一个对象(被观察者)的状态.这样,就可以在 ...
- (五)用正则化(Regularization)来解决过拟合
1 过拟合 过拟合就是训练模型的过程中,模型过度拟合训练数据,而不能很好的泛化到测试数据集上.出现over-fitting的原因是多方面的: 1) 训练数据过少,数据量与数据噪声是成反比的,少量数据导 ...
- 一段实现页面上的图片延时加载的js
大家如果使用firebug去查看的话就会发现,当你滚动到相应的行时,当前行的图片才即时加载的,这样子的话页面在打开只加可视区域的图片,而其它隐藏的图片则不加载,一定程序上加快了页面加载的速度,对于比较 ...
- 关于jdbc收集
一.如果我这样获得一个resultset ResultSet rs=statment.execquery("select * from tab"我如何能够从resultset中获得 ...
- [教程] Windows Server 2008 R2架设SMTP服务器发送邮件教程
Windows Server 2008 R2 架设SMTP服务器实现邮件发送 目的:架设SMTP服务器实现邮件发送. 一.域名设置 添加“邮件交换记录(MX)”: Newjs.cn ...