周末提交代碼,把代碼push到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
表示遠程推送不再支持密碼驗證了,改成 token 驗證了。
解決方案
- 首先要生成token,在 github 上找到setting -> Developer settings ->Personal access tokens->Generate new token
在配置頁面配置好權限后,即可生成token,注意這里需要保存好token,因為只顯示一次。
- 設置token,這里分成兩種情況,代碼已經有的,遠程倉庫地址添加token;沒有代碼的,在git clone添加token
- 修改遠程倉庫添加token
git remote set-url origin https://<your_token>@github.com/<USERNAME>/<REPO>.git
- git clone 添加token
git clone https://<your_token>@github.com/<USERNAME>/<REPO>.git
添加好token就可以推送和下拉代碼了。
遇到的坑
- 在idea上的github上設置token沒效果,這個具體原因未知
- 網上一大堆介紹如果生成token,但是重點是第二步,添加或者更新token。