Gitlab https拉取代码缓存用户密码配置小记

起因

业务服务器安全加固不再允许使用个人私有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': [email protected] 

#输入git密码
Password for 'https://kevin@[email protected]': 

成功首次代码拉取之后,在设置的缓存的时间周期内将不会再要求输入密码!

猜你喜欢

转载自blog.51cto.com/michaelkang/2460162