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

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

$ 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'

为了避免凭证缓存…

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


当前回答

为了添加到@ericbn的https://stackoverflow.com/a/41111629/579827,我在一个脚本中嵌入了一些示例命令,以便在密码更新时更新它们。它可能不是可用的,因为它是非常具体的,但它显示了cmdkey.exe的实际使用。

机场当局:这是在cygwin机场运行的shell程式码 机场当局说:“这是有效的,因为我使用私人git回购系统,所有的验证都使用相同的密码(你可能不想重复使用相同的凭据,但你可以重复使用这个样例/列表命令来提取已注册凭据的列表)

entries=`cmdkey.exe /list: | grep git | sed -r -e 's/^[^:]+:\s*(.*)$/\1/gm'`
for entry in ${entries}
do
    cmdkey.exe "/delete:${entry}"
    cmdkey.exe "/generic:${entry}" "/user:${GIT_USERNAME}" "/pass:${GIT_PASSWORD}"
done

其他回答

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

当您在同一台机器上使用多个Git帐户时,将出现此错误。

如果你使用的是macOS,那么你可以删除github.com保存的凭据。

请按照以下步骤删除github.com凭据。

开放钥匙串访问 找到github 选择github.com并右键单击它 删除“github.com” 再次尝试推或拉git,它将要求凭据。 为存储库帐户输入有效凭据。 完成

Git凭据缓存运行一个守护进程,该进程将您的凭据缓存到内存中,并根据需要分发它们。因此,如果您继续使用git-credential-cache- daemon作为缓存,那么终止git-credential-cache- daemon进程将丢弃所有这些,并导致重新提示您输入密码。辅助选项。

你也可以使用Git config——global——unset credential.helper禁用Git凭据缓存。然后重新设置,您将继续拥有缓存的凭据,可用于其他存储库(如果有的话)。你可能还需要执行git config——system——unset credential命令。如果在系统配置文件(例如,Windows 2的Git)中已经设置了helper。

On Windows you might be better off using the manager helper (git config --global credential.helper manager). This stores your credentials in the Windows credential store which has a Control Panel interface where you can delete or edit your stored credentials. With this store, your details are secured by your Windows login and can persist over multiple sessions. The manager helper included in Git for Windows 2.x has replaced the earlier wincred helper that was added in Git for Windows 1.8.1.1. A similar helper called winstore is also available online and was used with GitExtensions as it offers a more GUI driven interface. The manager helper offers the same GUI interface as winstore.

从Windows 10支持页面提取详细的Windows凭据管理器:

要打开凭据管理器,请在任务栏上的搜索框中输入“凭据管理器”,然后选择凭据管理器控制面板。

然后选择Windows凭证来编辑(=删除或修改)存储的给定URL的git凭证。

在我们的例子中,清除用户的.git-credentials文件中的密码是有效的。

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

在Windows 2003服务器的“wincred”*,没有其他答案帮助我。我必须使用cmdkey。

Cmdkey /list列出所有存储的凭证。 cmdkey /delete:Target删除名称为“Target”的凭据。

(*这里的“wincred”指的是git配置——全局凭据。助手wincred)