3 回答

TA贡献1831条经验 获得超10个赞
跑
git config --global credential.helper store
然后
git pull
提供用户名和密码,这些详细信息将在以后被记住。凭据存储在磁盘上的文件中,磁盘权限为“仅用户可读/可写”,但仍为纯文本格式。
如果您以后想要更改密码
git pull
将会失败,因为密码不正确,然后git从~/.git-credentials文件中删除有问题的用户+密码,因此现在重新运行
git pull
提供一个新密码,使其可以更早地工作。

TA贡献1825条经验 获得超6个赞
您可以使用git config启用git中的凭据存储。
git config --global credential.helper store
运行此命令时,第一次从远程存储库中拉出或推送时,系统会询问您用户名和密码。
之后,为了与远程存储库进行后续通信,您无需提供用户名和密码。
存储格式是.git-credentials文件,以纯文本格式存储。
此外,您还可以将其他帮助程序用于git config credential.helper,即内存缓存:
git config credential.helper cache <timeout>
这需要一个可选的timeout parameter,确定凭据将在内存中保留多长时间。使用帮助程序,凭据将永远不会接触磁盘,并且在指定的超时后将被删除。该default值是900 seconds (15 minutes).
警告:如果您使用此方法,则您的git帐户密码将以plaintext格式保存global .gitconfig file,例如,在linux中为/home/[username]/.gitconfig
如果您不希望这样做,ssh key请改为使用。

TA贡献1847条经验 获得超7个赞
打开凭据助手,以便Git将您的密码保存在内存中一段时间:
在终端中,输入以下内容:
# Set git to use the credential memory cache
git config --global credential.helper cache
默认情况下,Git会将您的密码缓存15分钟。
要更改默认密码缓存超时,请输入以下内容:
# Set the cache to timeout after 1 hour (setting is in seconds)
git config --global credential.helper 'cache --timeout=3600'
从GitHub帮助
- 3 回答
- 0 关注
- 2845 浏览
添加回答
举报