github用个人访问令牌上传仓库
github初始化一个repo都有一个上传指引之类的,就不说了
正常来说,下面就是按照指引的流程:
git init
git add .
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/xxx/xxx.git
git push -u origin main
但是在执行最后一条指令的时候:
Username for 'https://github.com': (邮箱名字,不是github的username)
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
噶?
解决: 官方链接:github官方教程 生成个人令牌 点击github头像–>Settings–>Developer settings–>Personal access tokens–>Generate new token Note:随便填 Expiration:不是很重要,选90 days就行 Selece Scope:不是很懂,简单粗暴全选
生成个人令牌之后:
git remote set-url origin https://<your_token>@github.com/<USERNAME>/<REPO>.git
按照这种格式重新设置一下远程url,继续push
git push -u origin main
我的出现:
fatal: unable to access 'https://.........git/': gnutls_handshake() failed: The TLS connection was non-properly terminated.
(网上有说设置代理什么的,我之前操作过,不知道是不是必须的) 我是继续执行一下git push就可以了(而可能是网络。。。)
结果就可以了:
克隆(没亲自操作过,先记着):
git clone https://<TOKEN>@github.com/<user_name>/<repo_name>.git
|