sourcetree使用personal Access Token连接Github

使用sourcetree推送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.
fatal: unable to access ‘https://github.com/xxx/xxx.git/’: The requested URL returned error: 403

这是因为github现在只能使用personal access token登录,

github上生成token的方法是,登录账号后,右上角头像->Settings->Developer settings->Personal access tokens->Generate new token

新创建token页面中,首先设置token的名字,用于辨识token的作用,之后选择token的有效期和设置token的权限作用域,完成后的token只会显示一次,建议找个地方保存一下。当然,以后token忘记了,也可以新建一个去使用。

sourcetree 修改方法:

Mac电脑在sourcetree中进入项目,点击右上角【设置】,选择远程仓库,把原本的https://github.com/xxx/yyyy.git修改成https://ghp_acRdgvdf68rdfsg@github.com/xxx/yyyy.git
格式是https://<your_token>@github.com/<USERNAME>/<REPO>.git

image.png

在命令行中,同样的使用该格式clone https仓库:

git clone https://<your_token>@github.com/<USERNAME>/<REPO>.git

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容