我使用BitBucket与Xcode和Git进行版本控制,最近我更改了我所有的密码(感谢Adobe!)
不出意外,我不能再把我的本地提交推到我在BitBucket上的存储库(“https://______.git”认证失败),但我忘记了如何更新iMac上缓存的密码。不知何故,我一直无法在谷歌或Stack Overflow上找到它,尽管在我看来它应该是相当直接的…
我使用BitBucket与Xcode和Git进行版本控制,最近我更改了我所有的密码(感谢Adobe!)
不出意外,我不能再把我的本地提交推到我在BitBucket上的存储库(“https://______.git”认证失败),但我忘记了如何更新iMac上缓存的密码。不知何故,我一直无法在谷歌或Stack Overflow上找到它,尽管在我看来它应该是相当直接的…
当前回答
如果您正在使用github并启用了2因素身份验证,则需要输入个人访问令牌而不是密码
首先重置密码:
Git配置——global——取消设置user.password
然后,登录到你的github账户,在右上角,点击设置,然后是开发者设置。生成一个个人访问令牌。复制它。
git push
终端将提示您输入您的用户名:输入您的电子邮件地址。
在密码提示符下,输入个人访问令牌。
其他回答
这个问题很混乱,因为这个问题太复杂了。首先是MacOS vs Win10。然后是不同的认证机制。
我将在这里开始一个统一的答案,可能需要一些帮助,如果我没有得到帮助,我会继续研究答案,直到它完成,但这需要时间。
Windows 10: |
|-- Run this command. You will be prompted on next push/pull to enter username and password:
| git config --global credential.helper wincred (Thanks to @Andrew Pye)
` MacOS:
|
|-- 1. Using git config to store username and password:
| git config --global --add user.password
|
|---- 1.1 first time entry
| git config --global --add user.password <new_pass>
|
|---- 1.2 password update
| git config --global --unset user.password
| git config --global --add user.password <new_pass>
|
|-- 2. Using keychain:
| git config --global credential.helper osxkeychain
|
|---- 2.1 first time entry
| Terminal will ask you for the username and password. Just enter it, it will be
| stored in keychain from then on.
|
|---- 2.2 password update
| Open keychain, delete the entry for the repository you are trying to use.
| (git remote -v will show you)
| On next use of git push or something that needs permissions, git will ask for
| the credentials, as it can not find them in the keychain anymore.
`
在Terminal执行以下步骤:
删除保存在Mac中的当前密码 Git配置——global——取消设置user.password 使用此命令添加您的新密码,替换为您的新密码: Git配置——global——添加用户。密码< new_pass >
对于Mac
如果你有多个远程存储库(Github, Bitbucket, Job等)
1)在项目目录下运行
git config --unset user.password
2)执行远程git命令。Git推还是Git拉)
Git将提示您重新输入user.name和user。此存储库的密码
如果只有一个远程存储库,也可以全局执行
git config --global --unset user.password
如果你是MAC用户,那么你可以从finder打开KeyChain访问应用程序,然后寻找你列出的帐户。只需点击它并更新你的密码。 现在试一试,一切都会迎刃而解。
链接参考:更新您的凭证通过钥匙链访问
在macOS上,例如在OSX v.11.6之后,应该进入KeyChain并搜索“git”。并删除相关键。它会起作用的。