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

当前回答

在Windows上,如果您在输入正确的密码和用户名时发现身份验证错误问题,那么这是Git的问题。要解决此问题,在机器上安装Git时,取消选中“启用Git凭据管理器”选项。

其他回答

我尝试了令牌验证方法,让它工作~3次,浪费了大约2个小时的时间。出于某种原因,它在我们公司不太适用。

我的解决方案是将身份验证方法从HTTPS改为SSH。这是一个Github指南(https://help.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent)。

创建SSH密钥后,请记住更改SSH地址来源:

git remote add origin git@github.com:user/repo.git

我添加到Bitbucket与Git链接,必须删除存储的密钥,因为这导致了致命的错误。

为了解决这个问题,我打开命令提示符并运行

 rundll32.exe keymgr.dll, KRShowKeyMgr

我删除了负责登录的密钥,下次我将文件推到repo时,系统会提示我输入凭据,并输入正确的凭据,结果成功推入。

确保您的SSH密钥已添加到当前SSH会话。

复制cat ~/.ssh/id_rsa的输出。pub到你的GitHub设置下的SSH和GPG密钥。 使用SSH -add ~/. SSH /id_rsa.pub更新当前的SSH会话。

我使用的是安装了OpenSSH的Windows PowerShell。

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

如果您在Windows上,并试图推送到具有域用户作为存储库用户(TFS)的Windows服务器,请尝试使用Internet Explorer进入TFS URL(即http:\\ TFS)。输入域帐户凭据并显示页面。

注意:只能使用ie浏览器!其他浏览器不会更改您的系统凭据。

现在转到Git Bash,更改存储库的远程用户,如下所示:

git config user.name "domainName\userName"

和完成。现在你可以推了!