这发生在大约3周前,当时他们说将删除到GitHub的https连接。当我试图推送时,这个Login UI就开始弹出,尽管我提供了正确的用户名和密码,但它说它是不正确的。然后促使我在bash/终端输入它,仍然说它是不正确的。
我设置了一个SSH键,一切都进行得很顺利,直到我试图按下,同样的情况再次发生。
安装了GitHub CLI,安装了一个全新的回购程序来测试这个问题,问题仍然存在!在过去的三个小时里,所有的文档和互联网上都在搜索,这让我抓狂。
希望你能给我一个解决方案的人。谢谢
编辑:我正在运行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)
EDIT2:
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就像这样出现,即使提供的用户名和密码是正确的,它也不会登录我。
在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/'
我按照在docs: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中的意图生成SSH密钥。
无论登录失败两次,也尝试从浏览器登录->登录,并且使用相同的凭据,都是毫无意义的。这里有什么事情要做吗?
EDIT3:网站(https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations) GitHub devs指向:
你今天需要做的事。对于开发人员来说,如果您今天使用密码来验证GitHub.com的Git操作,您必须在2021年8月13日前开始使用HTTPS (推荐的)个人访问令牌或SSH密钥,以避免中断。如果收到警告说您正在使用过时的第三方集成,则应将客户端更新为最新版本。
我在HTTPS上使用SSH,问题仍然存在。
EDIT4:用个人访问令牌登录是有效的!
来自吉突布:
个人访问令牌功能类似于普通的OAuth访问令牌。它们可以用来代替HTTPS上的Git密码,也可以用于通过基本身份验证对API进行身份验证。
PAT被视为密码,我使用它来代替我的密码,它将本地回购推送到远程回购。
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'.
解决了!
发布于 2021-09-07 07:55:17
出于安全考虑,开发人员于2021年8月13日取消了对密码认证的支持。他们建议使用个人访问令牌。
若要创建令牌:
来自您的settings
若要使用令牌:
当提示登录/验证时,用令牌替换密码。注意: PAT不适用于UI,但它是从cmd提示符开始工作的
若要缓存凭据并停止每次提交时出现提示:
gh auth login
按照提示>将HTTPS设置为首选协议>在最后一步中粘贴PAT。
现在你迷上了,准备走了
链接:https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/
发布于 2021-09-07 14:37:27
当您安装了Git的最新版本时,它提供了安装Git凭据Manager Core的功能,它提供了所有连接到GitHub、BitBucket和Azure DevOps的最新方法。这是最容易使用的场景,应该适用于Windows、Mac和Linux。gcm-核心将为您生成和管理PAT。
如果您正在使用WSL,则可能需要分别安装gcm-core并执行第二次授权。
C:\Program Files (x86)\Git Credential Manager Core>git-credential-manager-core.exe --version
2.0.498+7ad55fb809
C:\Program Files\Git\cmd>git --version
git version 2.33.0.windows.1
您可以在这里下载它们,git的最新安装程序应该附带gcm-core:
当您运行安装程序时,它可能会被关闭:
您的git配置可能正在查看旧的、不再维护的Git凭据管理器for Windows,在该配置中,您可能不得不将其强制转换到更新的版本:
运行git-credential-manager-core configure
使其在全局git配置中自动注册:
C:\Program Files (x86)\Git Credential Manager Core>git-credential-manager-core.exe configure
Configuring component 'Git Credential Manager'...
Configuring component 'Azure Repos provider'...
您的密码将存储在Windows凭据管理器中,
如果您遇到问题,在那里清除它们可能会让Git提示输入新的creds:
克隆现在将提示Git打开一个auth提示符:
您可以在此输入PAT令牌,也可以授权Git凭据Manager Core代表您在本地管理PAT令牌。它将为您打开浏览器或将URL写入提示符,以便您执行以下操作:
可能会提示您验证您的身份:
然后,克隆、推送或其他你所做的一切都应该像预期的那样起作用:
您现在应该在Windows凭据管理器中看到一个新的或更新的条目:
发布于 2021-09-06 22:59:48
git config --global user.email "your github email"
git config --global user.name "your user name on github"
git remote set-url origin https://github.com/your repo name.git
those may work
https://stackoverflow.com/questions/69080883
复制相似问题