我使用BitBucket与Xcode和Git进行版本控制,最近我更改了我所有的密码(感谢Adobe!)
不出意外,我不能再把我的本地提交推到我在BitBucket上的存储库(“https://______.git”认证失败),但我忘记了如何更新iMac上缓存的密码。不知何故,我一直无法在谷歌或Stack Overflow上找到它,尽管在我看来它应该是相当直接的…
我使用BitBucket与Xcode和Git进行版本控制,最近我更改了我所有的密码(感谢Adobe!)
不出意外,我不能再把我的本地提交推到我在BitBucket上的存储库(“https://______.git”认证失败),但我忘记了如何更新iMac上缓存的密码。不知何故,我一直无法在谷歌或Stack Overflow上找到它,尽管在我看来它应该是相当直接的…
当前回答
您可以在2个地方通过命令行更改密码,下面将编辑凭证以连接repo
git config --edit
凭据也可以在全局中使用如下所示的全局参数进行更改
git config --global --add user.password "XXXX"
或将凭据助手设置为
git config --global credential.helper wincred
但如果你有回购级别的凭据设置使用第一个命令
git config --edit
其他回答
考虑到2021年8月13日起新的令牌身份验证要求,这可能就是你想要的:
生成一个新的访问令牌
更新用于访问您的回购的令牌
git remote remove origin
git remote add origin https://[TOKEN]@github.com/[USER]/[REPO]
git push
要在macOS上修复此问题,可以使用
git config --global credential.helper osxkeychain
您的下一个Git操作(拉、克隆、推等)将出现用户名和密码提示。
对于Windows,它是相同的命令,但参数不同:
git config --global credential.helper wincred
我遇到了同样的问题,接受的答案没有帮助我,因为密码没有存储在钥匙链中。我输入:
git pull https://myuser@bitbucket.org/mypath/myrepo.git
然后控制台要求我输入新密码。
终端内的命令行选项对我都不起作用。最终,我只是手动打开钥匙链,在“所有项目”下搜索“git”,在那里找到一个条目并删除了它。成功了!下一次我试着从终端机拉一个git,它提示我新的信用。
这个问题很混乱,因为这个问题太复杂了。首先是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.
`