我已经使用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 = ############

当前回答

当我更新我的电脑密码时,得到上述错误信息。 使用以下步骤重置我的git凭证:

进入控制面板>用户帐户>凭据管理器> Windows凭据。您将在列表中看到Git凭据(例如Git:https://).)点击它,更新密码,然后在git bash中执行git pull/push命令,它就不会抛出任何错误消息了。

其他回答

我也遇到了错误(这就是为什么我被降落在这里),但没有一个建议对我有用。这是我第一次尝试将本地Git存储库部署到Azure。

当我得到这个错误,我重置了我的凭证(通过点击链接在Azure)几次尝试后。问题是,在这一点上,它告诉我我的用户名已经被占用,所以我也把我的用户名改为另一个。

最后,我手动删除了本地驱动器上的.git文件夹,并毫无问题地重新部署了它。

我认为由于某种原因,GitHub期望URL没有子域www。当我使用(例如)

git remote set-url origin https://www.github.com/name/repo.git

它给出了以下信息:

remote: Anonymous access to name/repo.git denied
fatal: Authentication failed for https://www.github.com/name/repo.git

然而,如果我使用

git remote set-url origin https://github.com/name/repo.git

它工作得非常好。这对我来说没什么意义…但我想记得不要把www放在GitHub存储库的远程URL中。

另外请注意,GitHub存储库网页上提供的克隆url不包括www。

如果问题存在,请提供正确的凭据:

如果你使用的是Android Studio 2.1测试版,那么这就是一个bug。升级到beta 2 (3 MB更新文件)。这对我很管用。

在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.

如果你在你的GitHub帐户上启用了双重身份验证,然后登录到你的GitHub帐户,然后转到

新的个人访问令牌

若要生成新的访问令牌,请复制该令牌,并将其作为密码粘贴到终端中进行身份验证。