Mac
1、长期存储
1.1 、前置条件
在终端中查看是否安装了credential-osxkeychain
git credential-osxkeychain
# Test for the cred helper
# Usage: git credential-osxkeychain <get|store|erase>
1.2、配置
告诉git使用osxkeychain使用全局credential.helper的配置:
git config --global credential.helper osxkeychain
# Set git to use the osxkeychain credential helper
2、短期存储
2.1、配置
设置凭据有效期,其单位为秒,下面表示1个小时后账号和密码将过期需要重新登录
git config credential.helper 'cache --timeout=3600'
使用 push / pull 代码 或 clone https链接项目都可免密登录,如果想删除凭据可以用以下命令
git config --system --unset credential.helper