我在多台计算机上工作,我会确保 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
右击,选择
Delete
如果要从 macOS 终端使用命令行,请键入
git credential-osxkeychain erase
host=github.com
protocol=https
关于git - 强制 git 始终要求输入密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48825943/