github推送代码报错

github

推送到github 远程仓库的时候报下面错误

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/wJiaLiang/pythonBasics.git/'

是因为自从21年 8月13 后不再支持用户名密码的方式验证,需要创建个人访问令牌(personal access token)。

解决办法如下:
在 GitHub 上生成令牌,对应仓库中设置

1.点击 settings
2.点击右侧的 Developer settings
3.点击 Personal access tokens(个人访问令牌) 选择 tokens (classic)
4.点击 Generate new token
5.设置 token 信息
6.根据所需过期时间,建议设置成永远,以免麻烦,建议所有选项都选上
7.点击 Generate token 生成令牌 复制生成的令牌
8.修改现有的 url
git remote set-url origin  https://<your_token>@github.com/<userName>/<project>.git
将<your_token>换成你自己得到的令牌。<userName>是你自己github的用户名,<project>是你的项目名称

在sourceTree中设置
1. 设置 菜单
2. 选择远程仓库地址设置为 https://your_token@github.com/userName/project.git 即可

报错2,提示如下错误 无法链接到服务

fatal: unable to access 'https://github.com/wJiaLiang/pythonBasics.git/': Failed to connect to github.com port 443 after 21123 ms: Couldn't connect to server
Pushing to https://github.com/wJiaLiang/pythonBasics.git

解决办法:

设置你代理的地址端口,`http://127.0.0.1:7890` 为自己的代理地址
设置:
git config --global http.proxy http://127.0.0.1:7890
git config --global https.proxy https://127.0.0.1:7890
取消:
git config --global --unset http.proxy
git config --global --unset https.proxy
posted @ 2023-07-27 14:36  kgwei  阅读(106)  评论(0编辑  收藏  举报