git - 强制 git 始终要求输入密码

标签 git macos passwords

我在多台计算机上工作,我会确保 git 在我推送时不会存储我的密码。所以简而言之,我希望 git 总是询问我的 github 密码。

那可能吗?

我比在 Mac 上感到沮丧,由于某种原因,它总是将我的密码存储在钥匙串(keychain)中,而且我每次都必须手动删除它。

我正在使用命令行。

编辑:

这个答案给了我解决问题的线索:

How do I disable git's credential helper for a single repository?

在终端运行这个:
git config --local credential.helper ''
或者,您可以编辑 .git/config 文件并拥有以下内容:
[credential] helper = ''
我没有 root 密码(出于某种原因,管理员密码不是有效的 root 密码,请看图)。

最佳答案

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

在 Windows 中:
通过单击开始按钮 打开用户帐户 开始按钮的图片、单击控制面板、单击用户帐户和家庭安全(或单击用户帐户,如果您连接到网络域),然后单击用户帐户。在左 Pane 中,单击管理您的凭据。
Windows 7:控制面板\用户帐户\凭据管理器

技巧:https://git-scm.com/book/en/v2/Git-Tools-Credential-Storage
您可以将记住权限超时更改为 0(零)。

macOS

尝试运行/Applications/Utilities/Keychain Access
enter image description here

enter image description here

右击,选择Delete
如果要从 macOS 终端使用命令行,请键入
git credential-osxkeychain erase
host=github.com
protocol=https

enter image description here

关于git - 强制 git 始终要求输入密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48825943/

相关文章:

windows - 在 Windows 上使用 SSH 的 Git

windows - Windows批处理下无法使用 "git.exe fetch origin"内的管道

swift - updateLayer() 上下文

macos - Mac 上 WebView 中的 Flash 插件与 Safari 中的 Flash 插件不同吗?它有定期的 Flash 垃圾收集吗?

c# - Mac 上的 MonoDevelop - 导出设置

passwords - 如何实现临时密码逻辑?

git - sourcetree 行结束问题

linux - 自定义 bash_profile 中的 git 命令以自动索引到下一个分支

php - 使用PHP比较MySql密码()

Grails - Spring Security 中相同盐的不同密码