週末提交程式碼,把程式碼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。