我已经使用GitHub有一段时间了,git添加、git提交和git推送都没问题,到目前为止还没有任何问题。突然我出现了一个错误

fatal:认证失败

在终端中,我克隆了一个存储库,处理了一个文件,然后我使用git add将文件添加到提交日志中,当我做git提交时,它工作得很好。最后,git push请求用户名和密码。我输入正确,每次我这样做,它都会显示相同的错误。

这个问题的原因是什么,我该如何解决它?

.git/config的内容如下:

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        url = http://www.github.com/######/Random-Python-Tests
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master
[user]
        name = #####
        email = ############

当前回答

我也有同样的问题。我这样设置URL:

git remote set-url origin https://github.com/zkirkland/Random-Python-Tests.git

我还从配置文件中删除了这个条目:askpass = /bin/echo。

然后“git push”问我的用户名和密码,这一次它成功了。

其他回答

如果您更改了git服务帐户(git)的登录名或密码,就会发生这种情况。你也需要在Windows凭证管理器中更改它。在Windows搜索菜单中输入“凭据管理器”打开它。

Windows凭证管理器->Windows凭证和在通用凭证下编辑您的git密码。

我的解决方案是:

C:\Users\USERNAME\AppData\Local\Atlassian\SourceTree的访问权限 找到文件passwd 右键单击该文件,用记事本打开 你会看到一个用户名和密码列表,如下所示:

username@dev.azure.com AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAMUOX3Q56PEuXEBSDFAFAASEH...

找到您输入错误的用户名和密码,并删除它 保存文件,并关闭它 SourceTree将在下一次推送或获取时再次询问您的用户名和密码

我也有同样的问题。重新启动我的系统后,它工作了。

启用凭据助手解决了我的问题。

在Windows上,尝试以下步骤编辑或删除保存的凭据:

Click Start Type: Credential Manager (on Windows 10, this is under "Start → Settings". Then search for "Credential Manager") See the Windows Credentials Manager shortcut and double-click it to open the application. Once the application is open, click on the Windows Credentials tab. Locate the credentials that you want to remove/update. They will start with "git:" and might begin with "ada:" Click on the credential entry. It will open a details view of the entry. Click Edit or Remove as required and confirm. Later rinse and repeat as necessary.