githup token 设置方法 - liutao932/c GitHub Wiki

引言 Github不能拉代码了?

今天我像往常那样更新一下Github代码,发现竟然报了下面的错误:

$ git pull 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. fatal: unable to access 'https://github.com//.git': The requested URL returned error: 403 1 2 3 4 意思是自从21年8月13后不再支持用户名密码的方式验证了,需要创建个人访问令牌(personal access token)。

解决 生成令牌 首先生成一个令牌,←链接是官网教程,也可以不点,直接看下文。

点击Settings

点击左侧的Developer settings

点击Personal access tokens(个人访问令牌)

点击Generate new token

设置token信息

点击Generate token生成令牌

得到生成的令牌

应用令牌 将生成的令牌拷贝下来(不要拷贝我的,拷贝你自己生成的!),记得保存,下次你就看不到了。

修改现有项目的url

git remote set-url origin https://<your_token>@github.com//.git 1 将<your_token>换成你自己得到的令牌。是你自己github的用户名,是你的项目名称,比如我的:

git remote set-url origin https://[email protected]/nlp-greyfoss/typora_notes.git/ 1 其实上面的报错中就有提示,不需要重新去找:

fatal: unable to access 'https://github.com//.git': 1 https://你的令牌@ \color{red}{\text{你的令牌@}}你的令牌@github.com//.git

然后再执行git pull,世界又恢复原样了。

船新版本 对于全新版本,克隆的时候也在github.com前面加个令牌就好了。

git clone https://@github.com/<user_name>/<repo_name>.git

参照:------------------------------ git remote set-url origin https://[email protected]/liutao932/c

⚠️ **GitHub.com Fallback** ⚠️