Git 推送导致“身份验证失败" [英] Git push results in "Authentication Failed"

查看:53
本文介绍了Git 推送导致“身份验证失败"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用 Github 一段时间了,到目前为止我对 git addgit commitgit push 都很好没有问题.突然,我遇到了一个错误:

I have been using Github for a little while and I have been fine with git add, git commit, and git push so far with no problems. Suddenly I am having an error that says:

致命:身份验证失败

在终端中,我克隆了一个存储库,处理了一个文件,然后我使用 git add 将文件添加到提交日志中,当我执行 git commit 时,它工作正常.最后,git push 要求输入用户名和密码.我把它们正确地放进去,每次我这样做时,它都会说同样的错误.

In the terminal I cloned a repository, worked on a file and then I used git add to add the file to the commit log and when I did git commit, it worked fine. Finally, git push asks for username and password. I put those in correctly and every time I do this, it says the same error.

有没有人知道这个问题的原因是什么,我该如何解决?

Does anyone have any idea what the cause of this problem is and how I can fix it?

.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 帐户中启用了双因素身份验证将无法使用您的帐户密码通过 HTTPS 推送.反而您需要生成个人访问令牌.这可以在您的 Github 帐户的应用程序设置.使用此令牌作为您的密码应该允许您通过 HTTPS 推送到远程存储库.照常使用您的用户名.

If you enabled two-factor authentication in your Github account you won't be able to push via HTTPS using your accounts password. Instead you need to generate a personal access token. This can be done in the application settings of your Github account. Using this token as your password should allow you to push to your remote repository via HTTPS. Use your username as usual.

https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/

如果设置为 https,您可能还需要更新存储库的源:

You may also need to update the origin for your repository if set to https:

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

这篇关于Git 推送导致“身份验证失败"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆