git credential.helper=cache永远不会忘记密码?

13

我希望我的密码被遗忘,这样我就不得不再次输入它。

我已经设置了这个:

git config credential.helper 'cache --timeout=600'

但是几天以后,它仍然记得密码,不再要求我输入...

git版本1.7.10.4(在Ubuntu上)

我遇到了一个bug吗?(因为我看到类似的问题,但是没有找到答案...)

编辑:还是我错过了什么吗?

编辑:现在我知道commit是本地的,而push是远程的。但是我的提交(使用RabbitVCS Git nautilus插件)似乎正在执行push作为远程repo正在更新...当我发布push时,它会要求输入密码...但是使用commit命令时,它不会要求并执行远程更新;我检查了4小时前我的commit已经更新了远程服务器:(


1
我面临的问题恰好相反 - 即使指定了999999(约11天)的超时时间,它甚至不记得半天。 - aalaap
1个回答

33

问题 1: 使用 Git 中的“忘记密码”功能。

问题 2(隐含): 配置设置相互矛盾。

答案:

git config --unset-all credential.helper
git config --global --unset-all credential.helper
git config --system --unset-all credential.helper

说明: Git 的配置分为三个地方:

  1. (仓库目录)/.git/config...........................适用于该仓库。
  2. ~/.gitconfig..........................适用于该用户。
  3. /etc/gitconfig.......................适用于这台系统的所有用户。

上述命令将删除与凭据相关的所有设置,包括仓库、用户和系统级别的设置,这应该回答了你的问题。

但是,看起来你的问题可能仅限于凭据帮助程序中一个选项——缓存,存在某种配置矛盾。如果您只想重置该选项,请执行以下操作:

git config --unset credential.helper 'cache'
git config --global --unset credential.helper 'cache'
git config --system --unset credential.helper 'cache'

...然后将超时设置为适当的级别,可以是以下任何一个:

git config --set credential.helper 'cache --timeout=600'
git config --global --set credential.helper 'cache --timeout=600'
git config --system --set credential.helper 'cache --timeout=600'

更多信息请参见这里的优秀文档:

  1. Git配置命令
  2. Git凭证缓存

6
对于更新版本的Git,请将--set更改为--add。(参见git help config中的文档。) - epineda
@HisHighnessDog 我已经创建了 $HOME/.config/git/credentials 并将 credential.helper 设置为 store,但在执行 git push 时它根本没有被使用。你有什么想法吗? - Dimitri Kopriwa

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接