如果通过
HTTP/HTTPS
连接 Git 远程仓库,每次都需要输入用户名密码,十分麻烦,教大家怎么让 Git 记住密码。
永久记住密码 (全局)
git config --global credential.helper store
会在~/.gitconfig
文件中生成下面的配置。
[credential]
helper = store
登录过后的账号密码,会记录在~/.git-credentials
文件中
格式:
协议://username:password@git域名
如:
http://tanpeng%40163.com:123456@git.thextrader.cn
如需只设置当前项目,则在当前项目下的.git/config
文件中添加。
当然,你也可以直接复制上面生成的配置到配置文件中。
临时记住密码
默认记住15分钟:
git config –global credential.helper cache
下面是自定义配置记住1小时:
git config credential.helper ‘cache –timeout=3600’