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.gitif you're updating to use HTTPSgit@github.com:USER/REPOSITORY_2.gitif 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-urlcommand.$ 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-urlcommand.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 更新默认 ...
随机推荐
- Android 的 ramdisk.img、system.img、userdata.img 作用说明,以及UBoot 系统启动过程
首先通過編譯,先將android內核編譯成功.正常情況下,在目錄out/target.product/generic/(但是有的就沒有generic文件,如freescale和iriver:但是lon ...
- 导出到Excel并且取消默认的科学计算法
导出Excel的代码很多,其中这种最简单: protected void btnDCAll_Click(object sender, EventArgs e) { ...
- iOS设备升级iOS7
引自:http://lifehacker.com/how-to-upgrade-to-ios-7-right-now-1288208215 Although iOS 7 won't see an of ...
- cs108 java 02
Eclipise 1. import, 所有的homework 是以 eclipse project directories 的形式. 所以要选择 “File –> Import “, Exis ...
- 【温故知新】c#事件event
从上一篇文章[温故知新]C#委托delegate可知,委托delegate和事件Event非常的相似,区别就是event关键字,给delegate穿上了个“马甲”. 让我们来看官方定义: 类或对象可以 ...
- WebForm页面运行机制
阅读目录 开始 WebForm前台与后台的关系及运行原理 前台页面 <% @ Page Language="C#" AutoEventWireup="true&qu ...
- XmlElement可以避免由XmlSerializer多余生成的代码
public class Program { static void Main(string[] args) { var alarm = new Alarm() { Code = "1588 ...
- HDU 5339 Untitled (暴力枚举)
题意:给定一个序列,要求从这个序列中挑出k个数字,使得n%a1%a2%a3....=0(顺序随你意).求k的最小值. 思路:排个序,从大的数开始模起,这是因为小的模完还能模大的么? 每个元素可以选,也 ...
- 新版Windows Azure CDN管理门户正式上线
经过产品团队的不懈努力,新版Windows Azure CDN管理门户在经过了有限开放预览之后,已经正式上线并开放给所有用户. 新版Windows Azure CDN管理门户经过全新的设计,除了在使用 ...
- dede栏目调用大全
A:侧边栏常用的当前栏目的父栏目调用(5.7) 1.在include/common.inc.php增加函数 function getTopCategoryName($cid=0) { global $ ...