您的位置:首页 > 理论基础 > 计算机网络

git操作之ssh与https互换

2017-08-23 12:14 141 查看
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]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  git