github在2021年8月份左右更新为只能通过token访问远程仓库,不再使用用户名和密码,挺坑的,记录以下解决方案,token替换掉了密码
github上生成token
Settings=> Developer Settings => Personal Access Token => Generate New Token
note这里写上一个自定的名称,需要记住,如lslall
token也要记住
配置.git/config
直接修改配置文件
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
ignorecase = true
[remote "origin"]
url = https://(这里填token的note)lslall:这里填access_token@github.com/用户名/项目名.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[user]
name = aa5279aa
email = xxxx@qq.com
[branch "develop"]
remote = origin
merge = refs/heads/develop
[credential]
helper =
配置凭据管理器
windows用户:在控制面板中找到:凭据管理器(Credential Manager) =》 Windows Credentials=》搜索github.com =》 编辑=》将密码替换为GitHub生成的Personal Access Token
重新配置远程仓库
这是第二种方法,重新执行配置远程仓库
# 移除原来的远程链接
git remote remove origin
# 查看git的远程链接
git remote -v
# 重新新增git远程链接
git remote add origin https://<your token>@github.com/<your account>/<your repository>.git
# 下拉master分支
git push origin master -u
\