GitHub使用Personal access token
报错: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/sober-orange/study.git/': The requested URL returned error: 403
原因:自2021年8月13日起,github不再支持使用密码push的方式
解决方案:两种
一、 使用SSH
二、使用Personal access token
法一:使用SSH
法二:使用Personal access token
首先,需要获取token
-
点击你的GitHub头像 -> 设置 -> 开发者设置 -> Personal access tokens -> Generate new token
-
使用token进行push、pull、clone等操作(pull和clone等操作原理同push,只需替换push为pull或其他相应的命令即可)
使用token的方式其实原理在于将原来明文密码换为token,说白了就是token>=password,之所以我这里写了>号,是因为token的功能远大于原来的password,相比password,token具有很多其没有的用法。
我将使用token的方法进行了细分,以满足不同的使用要求。请各位根据自己的使用情况进行选择token法一:直接push
此方法每次push都需要输一遍token,很是费劲啊
# git push https://你的token@你的仓库链接,我这里是我的仓库链接你要改成你的 git push https://你的token@github.com/sober-orange/study.git
token法二:修改remote别名
这种方式在push的时候直接指明别名就可
如果你已经设置过remote别名,使用如下命令# 我这里的别名是origin # git remote set-url 你的remote别名 https://你的token@你的仓库地址 git remote set-url origin https://你的token@github.com/sober-orange/study.git # 提交代码 git push -u origin master
如果你未设置过别名,使用如下命令添加别名
# git remote add 别名 https://你的token@你的仓库地址 git remote add origin https://你的token@github.com/sober-orange/study.git # 提交代码 git push -u origin master
token法三:使用Git Credential Manager Core (GCM Core) 记住token
git push Username: 你的用户名 Password: 你的token # 记住token git config credential.helper store
toekn法四:使用Windows的凭据管理器
- 打开凭据管理器 -> windows凭据
- 找到“git:https://github.com”的条目,编辑它
- 用token替换你以前的密码
参考文献
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
2020-09-10 测试面试题集-测试用例设计(3)