周末提交代碼,把代碼push到github上,控制臺(tái)報(bào)了下面的錯(cuò)誤:
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
表示遠(yuǎn)程推送不再支持密碼驗(yàn)證了,改成 token 驗(yàn)證了。
解決方案
- 首先要生成token,在 github 上找到setting -> Developer settings ->Personal access tokens->Generate new token
找到生成token路徑
在配置頁面配置好權(quán)限后,即可生成token,注意這里需要保存好token,因?yàn)橹伙@示一次。
- 設(shè)置token,這里分成兩種情況,代碼已經(jīng)有的,遠(yuǎn)程倉庫地址添加token;沒有代碼的,在git clone添加token
- 修改遠(yuǎn)程倉庫添加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上設(shè)置token沒效果,這個(gè)具體原因未知
- 網(wǎng)上一大堆介紹如果生成token,但是重點(diǎn)是第二步,添加或者更新token。
