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

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

$ 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-credentials文件中的密码是有效的。

c:\users\[username]\.git-credentials

其他回答

我找到了适合我的方法。当我给OP写注释时,我没有检查系统配置文件:

git config --system -l

显示了一个

credential.helper=!github --credentials

线。我用

git config --system --unset credential.helper

现在这些证书都被遗忘了。

当上面提到的方法对你都不起作用时,试试这个方法。

git config credential.helper 'cache --timeout=30'

这将每隔3秒删除缓存,并询问用户名和密码。可以重新运行增加超时值的命令。

如果您使用密钥对进行身份验证,则可以删除或移动您的私有密钥,或者停止密钥代理并尝试。

这种方法对我来说是有效的,并且不受操作系统的影响。这有点笨拙,但很快,让我重新输入凭证。

只需找到您希望重新输入凭据的远程别名。

$ git remote -v 
origin  https://bitbucket.org/org/~username/your-project.git (fetch)
origin  https://bitbucket.org/org/~username/your-project.git (push)

复制项目路径(https://bitbucket.org/org/~username/your-project.git)

然后取下遥控器

$ git remote remove origin

然后再加回去

$ git remote add origin https://bitbucket.org/org/~username/your-project.git

如果你的凭据存储在凭据助手中(通常情况下),移除特定主机的密码持久化的可移植方法是调用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