SourceTree Push 代码报错:remote: Support for password authentication was removed on April 26, 2022.
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
1、在个人设置页面
,找到Setting
![](https://upload-images.jianshu.io/upload_images/965192-f6159b8aa1d2546e.png?imageMogr2/auto-orient/strip|imageView2/2/w/368)
2、在左侧列表中,选择开发者设置Developer setting
![](https://upload-images.jianshu.io/upload_images/965192-ca8be3d46bf4e132.png?imageMogr2/auto-orient/strip|imageView2/2/w/452)
3、选择个人访问令牌Personal access tokens,然后选中生成令牌Generate new token
![](https://upload-images.jianshu.io/upload_images/965192-27765a6a41fba801.png?imageMogr2/auto-orient/strip|imageView2/2/w/1200)
4、设置token的有效期,访问权限等
选择要授予此令牌token的范围或权限。
要使用token从命令行访问仓库,请选择repo。
要使用token从命令行删除仓库,请选择delete_repo
其他根据需要进行勾选
![](https://upload-images.jianshu.io/upload_images/965192-ccdaf7c98fe930d3.png?imageMogr2/auto-orient/strip|imageView2/2/w/1200)
截屏2021-08-16 下午2.46.06.png
5、生成令牌Generate token
![](https://upload-images.jianshu.io/upload_images/965192-ca1e50d5bf3011e5.png?imageMogr2/auto-orient/strip|imageView2/2/w/1200)
token生成成功!
![](https://upload-images.jianshu.io/upload_images/965192-c99de9ac2b7b2e8a.png?imageMogr2/auto-orient/strip|imageView2/2/w/1200)
注意:
记得把你的token保存下来,因为你再次刷新网页的时候,你已经没有办法看到它了!
6、之后用自己生成的token登录,把上面生成的token粘贴到输入密码的位置,然后成功push代码!
也可以 把token直接添加远程仓库链接中,这样就可以避免同一个仓库每次提交代码都要输入token了:
(1) 在sourceTree中操作,点击右上角设置
![](https://upload-images.jianshu.io/upload_images/965192-073cbb603da0a372.png?imageMogr2/auto-orient/strip|imageView2/2/w/1200)
(2) 编辑远程仓库链接
![](https://upload-images.jianshu.io/upload_images/965192-50c245602ae92b18.png?imageMogr2/auto-orient/strip|imageView2/2/w/1126)
git remote set-url origin https://<your_token>@github.com/<USERNAME>/<REPO>.git <your_token>:换成你自己得到的token <USERNAME>:是你自己github的用户名 <REPO>:是你的仓库名称
例如:
git remote set-url origin https://ghp_xxxxxxxxxxxxxxxxxx@github.com/ZhangSan/TestProj.git/