"配置Github使用Token登录验证" 修訂間的差異
出自 YTYZX有图有真相的百科
(未顯示同一使用者於中間所作的 2 次修訂) | |||
行 1: | 行 1: | ||
− | 使用“git push origin main”推送代码到github时报如下错误: | + | 背景: 使用“git push origin main”推送代码到github时报如下错误: |
remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead. | 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. | remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information. | ||
− | |||
大意为:github在2021年8月13日移除密码认证的支持,在使用命令行或API的时候,建议创建一个个人访问令牌(personal access token)来代替密码 | 大意为:github在2021年8月13日移除密码认证的支持,在使用命令行或API的时候,建议创建一个个人访问令牌(personal access token)来代替密码 | ||
− | 1.登录github后在页面右上角点击您的头像。 | + | |
+ | 1.登录github后在页面右上角点击您的头像 ,点击“Settings”按钮 。 | ||
[[File:GithubToken1.png]] | [[File:GithubToken1.png]] | ||
− | 2. | + | 2. 在左侧边栏中,点击Developer settings(开发人员设置)。 |
− | + | ||
+ | [[File:GithubToken2.png]] | ||
+ | |||
+ | 3.点击“Personal access tokens”。 | ||
+ | [[File:GithubToken3.png]] | ||
+ | |||
+ | 4.点击右上角的“Generate new token”按钮。 | ||
+ | [[File:GithubToken4.png]] | ||
+ | |||
+ | 5. 输入 登录github页面的密码。 | ||
+ | [[File:GithubToken5.png]] | ||
+ | |||
+ | 6.输入Token的名称(任意名称均可)和失效时间。 | ||
+ | [[File:GithubToken6.png]] | ||
+ | |||
+ | 7.点击选择需要赋予的权限。 | ||
+ | [[File:GithubToken7.gif]] | ||
+ | |||
+ | 8.在左下角点击“Generate token”按钮(拖动滚动栏即可看到)。 | ||
+ | [[File:GithubToken8.png]] | ||
+ | |||
+ | 9.显示的 令牌 如下(可点击对应按钮复制或者删除)。 | ||
+ | [[File:GithubToken9.png]] | ||
+ | |||
+ | 10.在Windows的控制面板里面找到凭据管理器更新及保存即可 。 | ||
+ | [[File:GithubToken10.png]] | ||
− | 例如 | + | 以后可通过 HTTPS 执行 Git 操作时输入令牌替换密码。 |
+ | 例如在命令行中输入以下内容: | ||
− | $ git clone https://github.com/username/repo.git | + | $ git clone https://github.com/username/repo.git |
− | Username: your_username | + | Username: your_username |
− | Password: your_token | + | Password: your_token |
於 2021年12月19日 (日) 14:27 的最新修訂
背景:使用「git push origin main」推送代碼到github時報如下錯誤: 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. 大意為:github在2021年8月13日移除密碼認證的支持,在使用命令行或API的時候,建議創建一個個人訪問令牌(personal access token)來代替密碼
1.登录github后在页面右上角点击您的头像,点击“Settings”按钮。
2.在左侧边栏中,点击Developer settings(开发人员设置)。
3.点击“Personal access tokens”。
4.点击右上角的“Generate new token”按钮。
5.输入登录github页面的密码。
6.输入Token的名称(任意名称均可)和失效时间。
7.点击选择需要赋予的权限。
8.在左下角点击“Generate token”按钮(拖动滚动栏即可看到)。
9.显示的令牌如下(可点击对应按钮复制或者删除)。
10.在Windows的控制面板里面找到凭据管理器更新及保存即可。
以后可通过 HTTPS 执行 Git 操作时输入令牌替换密码。 例如在命令行中输入以下内容:
$ git clone https://github.com/username/repo.git Username: your_username Password: your_token