略微加速

略速 - 互联网笔记

git操作之ssh与https互换

2019-05-29 leiting (2165阅读)

标签 Git

git ssh 与 https 互换

我的情况是原本使用ssh,但是ssh突然使用不了,需要跟换https

步骤:

1)修改远程仓库地址

方法有三种:



1.修改命令



git remote set-url origin [url]

我这里使用 git remote set-url origin [url]命令,直接修改远程仓库为https的地址



2.先删后加



git remote rm origin

git remote add origin [url]



3.直接修改config文件





2)以上进行git操作的时候,每次都需要密码,所以可以配置免密

1)新建文件并保存密码

$ touch ~/.git-credentials

$ vim ~/.git-credentials

2)添加内容

https://{username}:{passwd}@github.com

3)添加git配置

$ git config --global credential.helper store



---------------------



如果想切回ssh,直接修改远程仓库的地址即可

例如:git remote set-url origin [ssh的url]

--------------------- 

作者:内心毫无波动甚至还想笑 

来源:CSDN 

原文:https://blog.csdn.net/yym836659673/article/details/77504430 

版权声明:本文为博主原创文章,转载请附上博文链接!


北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3