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

当前回答

我得到以下错误时,试图推动到github远程

git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

解决方案 github账户上的SSH密钥丢失

从~/复制本地公共ssh密钥。ssh目录 粘贴到Github >设置> SSH和GPG密钥>新的SSH密钥 试试ssh -T git@github.com 这应该会输出 嗨xxxxx !您已成功验证,但GitHub不提供shell 访问。

其他回答

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

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

问题说明:“git fatal authentication failed”。我在用Bitbucket。

解决方案:

我只是删除了使用Bitbucket访问管理的用户,然后添加了相同的用户。.gitconfig文件很简单:

[user]
    name = BlaBla
    email = blabla@gmail.com

[push]
    default = simple

同样的错误(Windows, Git Bash命令行)。使用https应该提示登录凭证,但错误:

$ git pull origin master
fatal: Authentication failed for 'https://github.com/frmbelz/my_git_project.git'
$ git config -l
...
credential.helper=manager
...

$ git config --global --unset credential.helper
$ git config --system --unset credential.helper

Git拉现在提示用户名/密码提示。

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

在Android Studio Canary 3.1+版本中,如果你正在使用Android Studio Git工具,那么你可以使用以下工具:

点击Android Studio 点击Preferences… 进入版本控制→GitHub 此处将验证类型更改为密码 此步骤将要求您输入登录名和密码。登录时输入GitHub用户名,密码为GitHub密码。 单击Test按钮。

如果连接成功,那么就完成了,可以使用Android Studio GitHub GUI客户端。