git之ssh与https地址之间的切换、设置免密码访问服务器、remote、set-url、config、global、credential、helper、store、cache、origin


1、查看当前属于什么地址的命令

git remote -v

如果当前处于ssh状态下会输出一下内容。

origin  git@gitee.com:mssj200224/open-resources.git (fetch)
origin  git@gitee.com:mssj200224/open-resources.git (push)

如果当前处于https状态下会输出一下内容。

origin  https://git@gitee.com:mssj200224/open-resources.git (fetch)
origin  https://git@gitee.com:mssj200224/open-resources.git (push)

2、从ssh切换至https

 git remote set-url origin https://git@gitee.com:mssj200224/open-resources.git

origin后面是远程仓库的https地址。


3、从https切换至ssh

git remote set-url origin git@gitee.com:mssj200224/open-resources.git

origin后面是远程仓库ssh地址。


4、设置密码

默认15分钟

git config --global credential.helper cache

自己定义时间,一小时后失效

git config credential.helper 'cache --timeout=3600'

永久存储密码

git config --global credential.helper store

猜你喜欢

转载自blog.csdn.net/weixin_51157081/article/details/125191412