今天,GitHub 提供了一种推送、克隆或拉取存储库的新方法,让我大吃一惊
当我尝试推送我的项目时,我收到此错误消息:
remote: Password authentication is temporarily disabled as part of a brownout. Please use a personal access token instead.
remote: Please see https://github.blog/2020-07-30-token-authentication-requirements-for-api-and-git-operations/ for more information.
fatal: unable to access 'https://github.com/barimehdi77/Philosophers.git/': The requested URL returned error: 403
Run Code Online (Sandbox Code Playgroud)
经过多次搜索,我发现 GitHub 添加了一个新的安全更新,名为Personal access tokens
but who can I use it?
Adr*_*eno 26
您必须使用 SSH 密钥。为每台计算机创建一个并将它们全部注册到您需要访问的存储库。这样做可以让您逐台删除对计算机的访问。
在 Github 中配置 SSH 密钥后,您可以阅读本文来设置个人访问令牌。
UPDATE它告诉你如何更改为文档中的令牌
在命令行上使用令牌
获得令牌后,您可以在通过 HTTPS 执行 Git 操作时输入该令牌而不是密码。
例如,在命令行上您可以输入以下内容:
$ git clone https://github.com/username/repo.git <--- HTTPS, not SSH
Username: your_username
Password: your_token <-------- THE TOKEN, not your password
Run Code Online (Sandbox Code Playgroud)
个人访问令牌只能用于 HTTPS Git 操作。如果您的存储库使用 SSH 远程 URL,则需要将远程从 SSH 切换为 HTTPS。
如果系统未提示您输入用户名和密码,则您的凭据可能会缓存在您的计算机上。您可以更新钥匙串中的凭据,以使用令牌替换旧密码。
您可以使用 Git 客户端缓存 PAT,而无需为每个 HTTPS Git 操作手动输入 PAT。Git 会将您的凭据临时存储在内存中,直到过期间隔结束。您还可以将令牌存储在 Git 可以在每次请求之前读取的纯文本文件中。有关更多信息,请参阅“在 Git 中缓存 GitHub 凭证”。
还发现了一个很好的视频演练,可能有助于澄清一些事情。
https://www.youtube.com/watch?v=kHkQnuYzwoo