前景问题提要:
在git push
时报错:remote: Support for password authentication was removed . 完整错误如下:
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: Authentication failed for 'https://gist.github.com/2df442f4031c39744a6fa71470d97f0a.git/'
网上解决方法挺多的,我的解决方法:
- 一些git命令
git config -l # 查看git配置信息
git remote show # 列出remote name
git remote show [remote-name] # 查看某个remote的远程仓库信息
- 问题1:remote: Repository not found.
remote: Repository not found.
fatal: repository 'https://github.com/MyRepo/project.git/' not found
解决方法:
# Step1: 修改git仓库配置
git remote show # 查看远程仓库
git remote show origin # 查看url是否配置正确,最好使用下面的 `git remote add...`格式配置
git remote remove origin # 按上2句命令列出的仓库名,删除
git remote add origin https://[personal-access-token]@github.com/username/repo_name.git # 重新添加远程仓库。
# Step2: push / pull,以pull 举例
git push --set-upstream origin master # 此时若需password,输入token即可
# Step3: 配置到计算机缓存。由于后面打开github网页密码不可见,现在配置到计算机缓存中
# 将给定的记录缓存到你的计算机中,以记住令牌:
git config --global credential.helper cache # 再使用`git config -l` 看是否保存成功
# 如果想要删除缓存记录:
git config --global --unset credential.helper
git config --system --unset credential.helper
注意:
我之前生成过一次 personal token,按照上面配置仍旧有误,重新生成personal token后,成功。
生成personal token 官方博客: