配置Github使用Token登錄驗證

從 YTYZX有图有真相的百科
於 2021年12月19日 (日) 14:14 由 Ytyzx (對話 | 貢獻) 所做的修訂
跳到: 導覽搜尋
背景:使用「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”按钮。

GithubToken1.png

2.在左侧边栏中,点击Developer settings(开发人员设置)。

GithubToken2.png

3.点击“Personal access tokens”。

GithubToken3.png

如果您有令牌,則可以在通過 HTTPS 執行 Git 操作時輸入令牌,而不是密碼。

例如,在命令行中輸入以下內容:

$ git clone https://github.com/username/repo.git Username: your_username Password: your_token