业务服务器安全加固不再允许使用个人私有key配置再服务器,为了配置调试方便使用https方式拉取代码,但是发现每次Git pull 、push 都要输入用户和密码,很不方便,特整理此配置。
会在用户家目录的.gitconfig文件中生成下面的配置。如果没有--global,则在当前项目下的.git/config文件中添加。
git config --global credential.helper store
默认记住15分钟:
git config –global credential.helper cache
下面是自定义配置记住1小时:
git config credential.helper ‘cache –timeout=3600’
cd /workspace/kdeploy
git pull
[root@kdeploy]# git pull
#输入git用户
Username for ‘https://gitlab.com‘: kevin@pxxxx.com
#输入git密码
Password for ‘https://kevin@xxxxcom@gitlab.com‘:
成功首次代码拉取之后,在设置的缓存的时间周期内将不会再要求输入密码!
原文:https://blog.51cto.com/michaelkang/2460162