问题描述
今天把自己翻译的一些内容提交到 GitHub 上,但是 push 后却提示下内容:
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/xxxx.git/': The requested URL returned error: 403
分析
一开始还以为是自己的网络出问题,通过再三确认后,发现不是自己网络的问题,于是直接将提示的关键词必应搜索,直接找到 csdn 的一个博客的解决方案,但是按照这位博主的方法,需要重新 clone 仓库,但我已经在原先的仓库基础上修改好了。如果重新 clone,势必要重新编辑文章内容,感觉繁琐,于是在生成了 ssh key 之后,我直接把仓库的 remote url 进行了更改,发现也能很好的解决问题。
解决方法
直接运行修改 remote url 的命令行即可:
git remote set-url origin git@github.com:userName/repoName.git
此时,再进行 gut push,此时会提示你是否使用该密钥指纹:
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])?
输入 yes 即可。
参考
- https://blog.csdn.net/cnds123321/article/details/119707957