我使用BitBucket与Xcode和Git进行版本控制,最近我更改了我所有的密码(感谢Adobe!)
不出意外,我不能再把我的本地提交推到我在BitBucket上的存储库(“https://______.git”认证失败),但我忘记了如何更新iMac上缓存的密码。不知何故,我一直无法在谷歌或Stack Overflow上找到它,尽管在我看来它应该是相当直接的…
我使用BitBucket与Xcode和Git进行版本控制,最近我更改了我所有的密码(感谢Adobe!)
不出意外,我不能再把我的本地提交推到我在BitBucket上的存储库(“https://______.git”认证失败),但我忘记了如何更新iMac上缓存的密码。不知何故,我一直无法在谷歌或Stack Overflow上找到它,尽管在我看来它应该是相当直接的…
当前回答
这个问题很混乱,因为这个问题太复杂了。首先是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.
`
其他回答
对于MAC用户,使用git GUI(适用于Sourcetree,也可能适用于其他用户)。我想对德里克的回答补充一点意见。原建议:
$ git config --global --unset user.password
应该跟着一个推/拉/取,但它可能不会工作时,从GUI。%100的工作情况是在控制台执行第一个连续的提示触发git命令。这里有一个例子:
定位到git存储库根目录 输入$ git config——unset user.password 在终端中执行您选择的git推荐,例如:$ git push
然后它会要求您提供新密码。
在windows 10中,正如上面提到的@Imran Javed,你可以在下面找到通用凭据:
控制面板\所有控制面板项\凭证管理器—> Windows凭证
找到你的git服务器,然后你可以通过点击编辑按钮更新密码。
这是我第一次推进仓库。所以没有定义HEAD。
最简单的方法是:
git push -u origin master
然后它会提示输入密码,一旦你输入密码,它就会自动保存,你就可以按了。
考虑到2021年8月13日起新的令牌身份验证要求,这可能就是你想要的:
生成一个新的访问令牌
更新用于访问您的回购的令牌
git remote remove origin
git remote add origin https://[TOKEN]@github.com/[USER]/[REPO]
git push
在mac BigSur 11.2.3 我更新了密钥链中的凭据,然后运行下面的命令。
git credential-osxkeychain erase
host=github.com
protocol=https
我不得不这样做,因为在这个线程中没有其他解决方案为我更改为github令牌认证后工作。Github一直说仓库没有找到。 如果这不起作用,尝试将此与此线程中mac的其他命令结合起来。