我正在使用几个存储库,但最近我只在我们的内部存储库中工作,一切都很好。

今天我不得不提交并将代码推到另一个,但我遇到了一些麻烦。

$ git push appharbor master
error: The requested URL returned error: 403 while accessing https://gavekortet@appharbor.com/mitivo.git/info/refs?service=git-receive-pack
fatal: HTTP request failed

没有什么我能做的,这将再次带来密码输入。

我如何重置系统上的凭据,以便Git询问我该存储库的密码?

我试过:

Git配置——global——unset core.askpass

以便取消设置密码

Git配置凭证。Helper '缓存超时=1'

为了避免凭证缓存…

似乎什么都不管用;谁有更好的主意?


当前回答

如果你的凭据存储在凭据助手中(通常情况下),移除特定主机的密码持久化的可移植方法是调用git credential reject:

一句话: $ echo "url=https://appharbor.com" | git证书拒绝 或交互: $ git凭证拒绝 = https协议 主机= gitlab.com 用户名= me@example.com ↵ (是回车符号),在输入结束时按两次回车键,不要复制/粘贴 wincred似乎无法识别用户名,因此避免在Windows上通过用户名进行过滤

然后,输入git fetch来输入新密码。

https://git-scm.com/docs/git-credential

其他回答

在PowerShell控制台中执行以下命令清除Windows缓存中的Git凭据管理器:

rm $env:LOCALAPPDATA\GitCredentialManager\tenant.cache

或在Cmd.exe中

rm %LOCALAPPDATA%\GitCredentialManager\tenant.cache

最终为我解决这个问题的是使用GitHub桌面,进入存储库设置,并从存储库url中删除user:pass@。然后,我尝试从命令行推送,并提示输入登录凭据。我把它们放进去之后,一切都恢复正常了。Visual Studio和命令行都可以工作,当然还有GitHub桌面。

GitHub Desktop->Repository->Repository Settings->Remote选项卡

将主远程存储库(origin)更改为:

https://pork@muffins@github.com/MyProject/MyProject.git

To:

https://github.com/MyProject/MyProject.git

点击“保存”

凭证将被清除。

请执行以下命令-

git config --global credential.helper cache

然后运行任何git命令,比如git pull,它会要求输入用户名和密码。输入详细信息,如果您想存储您的git凭据,请运行以下命令-

git config --global credential.helper store

至少在Windows上,git remote show [remote-name]可以工作。

git remote show origin

在我的Win 10上,找不到Windows凭据管理器和。git-credentials。 有效的方法是打开Git GUI并推送代码。然后它请求凭据,这也更新了我Git Bash缓存的密码。