这发生在大约 3 周前,当时他们表示将删除与 GitHub 的 https 连接。那时,每当我尝试推送时,此登录 UI 就会开始弹出,即使我提供了正确的用户名和密码,它也会说它不正确。然后提示我在 bash/terminal 中输入它,仍然说它不正确。
我设置了一个 SSH 密钥,一切都很顺利,直到我尝试推送并且同样的事情再次发生。
安装了 GitHub CLI,设置了一个全新的 repo 来测试它,问题仍然存在!过去 3 个小时一直在搜索所有文档和互联网,这让我发疯。
希望您为我提供解决方案。谢谢
编辑:我正在运行 git 版本 2.26.0.windows.1
输入时输出git remote -v
:
origin https://github.com/marjotoska/website-mock-test.git (fetch)
origin https://github.com/marjotoska/website-mock-test.git (push)
编辑2:
git push
fatal: The current branch main has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin main
git push --set-upstream origin main
Logon failed, use ctrl+c to cancel basic credential prompt.
然后登录界面就这样出现了,即使提供的用户名和密码是正确的,它也不会让我登录。
该 UI 失败后,从 cmd 登录也失败:
Username for 'https://github.com': marjotoska
Password for 'https://marjotoska@github.com':
remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.
fatal: Authentication failed for 'https://github.com/marjotoska/website-mock-test.git/'
我按照文档中的预期方式生成了 SSH 密钥:https ://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh/generating-a-new-ssh -key-and-adding-it-to-the-ssh-agent
登录失败两次是没有意义的,还尝试了从浏览器注销->登录,并且使用相同的凭据可以正常工作。这里有什么可以做的吗?
EDIT3:网站(https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations)GitHub开发人员指向:
你今天需要做什么。对于开发人员,如果您现在使用密码对 GitHub.com 的 Git 操作进行身份验证,则必须在 2021 年 8 月 13 日之前通过 HTTPS(推荐)或 SSH 密钥开始使用个人访问令牌,以避免中断。如果您收到警告说您正在使用过时的第三方集成,您应该将您的客户端更新到最新版本。
我正在通过 HTTPS 使用 SSH,但问题仍然存在。
EDIT4:使用个人访问令牌登录有效!!!
来自 Github:
个人访问令牌的功能类似于普通的 OAuth 访问令牌。它们可用于通过 HTTPS 代替 Git 的密码,或可用于通过基本身份验证对 API 进行身份验证。
PAT 被视为密码,我用它代替了我的密码,这将本地 repo 推送到了远程 repo
Logon failed, use ctrl+c to cancel basic credential prompt.
Username for 'https://github.com': marjotoska
Password for 'https://marjotoska@github.com':
Enumerating objects: 27, done.
Counting objects: 100% (27/27), done.
Delta compression using up to 8 threads
Compressing objects: 100% (25/25), done.
Writing objects: 100% (27/27), 106.63 KiB | 8.20 MiB/s, done.
Total 27 (delta 3), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (3/3), done.
To https://github.com/marjotoska/website-mock-test.git
* [new branch] main -> main
Branch 'main' set up to track remote branch 'main' from 'origin'.
解决了!