我已经使用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的http身份验证问题的一个热门:Windows凭据管理器已经正确地存储了我的密码,并且由于我使用git LFS,我配置了一个http URL而不是通常的ssh://。

我的问题是,我的公司密码策略强制更改帐户密码,但我从未更新我存储的凭据(因为我总是使用ssh密钥)。

简单地在Wincred GUI中直接更新密码就可以了:只需查找git:https://<your-url>条目。

其他回答

给定的解决方案:使用个人访问令牌是绕过此问题的一种方法。我没有启用双重身份验证,但每当我登录到一台新PC时,我都会收到电子邮件验证码来验证PC。

解决方案: 你可以在浏览器上登录到GitHub并验证你的身份,这将让GitHub知道信任这台PC。然后,使用bash登录,这一次您的登录应该像往常一样工作,因为现在您被列入了白名单。


注意:如果你有任何现有的GitHub帐户,想要切换,那么,在凭证管理器> Windows凭证(通用凭证部分)中删除它。这样做将允许您在进行另一个git操作时登录。

基本上我的证书过期了,我面临着这个问题。

下面两个命令帮助了我:

git config --global --unset credential.helper

git config credential.helper store

当你下次尝试推送时,它会要求你提供凭证。

有关用户名和密码的安全和不安全存储的详细信息,请遵循以下指南:

git-credential-store git-credential-cache

就在这里,为我解决问题的是,我只是取消了最初的提示,SSH与我的Bitbucket帐户打开,我在那里输入密码,一切正常。

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

在你尝试以上一切之前,尝试git再推一次,是的,它对我有用。