美文网首页
2019-06-16 sourcetree使用http方式不断要

2019-06-16 sourcetree使用http方式不断要

作者: 路飞戎 | 来源:发表于2019-06-17 11:36 被阅读0次

在使用Git进行开发的时候,我们可以使用ssh url或者http url来进行源码的clone/push/pull。
二者的区别是:
1.使用ssh url需要在本地配置ssh key,这也就意味着你必须是开发者或者有一定的权限,每次的代码同步(主要是push和clone)不需要进行用户名和密码的输入操作
2.使用http url相对宽松些,但是需要在每次同步操作输入用户名和密码,有时候,为了省去每次都输入密码的重复操作,我们可以在本地新建一个文件,来存储你的用户名和密码,只需要在第一次clone输入用户名和密码,这些信息就被存储起来,以后就可以自动读取,不需要你在手动输入了。 在Git官网介绍了这一实现,是通过叫做credential helper的小玩意儿实现的。可以把它叫做证书或者凭证小助手,它帮我们存储了credential(凭证,里面包含了用户名和密码)

主要说一下http
具体操作:
1.先查看先查看我们系统支持哪种helper
git help -a | grep credential

2.设置credential helper

vim .git-credentials

如果不存在,会创建一个新的文件,创建完成后,在该文件中输入:

http://username:password@github.com

保存退出
执行

git config --global credential.helper store

store为永久存储,当然也可以设置临时的

git config –global credential.helper cache

默认为15分钟,如果想设置保存时间的话,可以输入

git config credential.helper ‘cache –timeout=3600’

3.查看配置

git config --list

发现配置文件多了一项

[credential]helper=store

相关文章

网友评论

      本文标题:2019-06-16 sourcetree使用http方式不断要

      本文链接:https://www.haomeiwen.com/subject/ywlnfctx.html