共计 649 个字符,预计需要花费 2 分钟才能阅读完成。
往年 8 月 13 日之后,如果你还用账户明码来操作 Github 上的仓库,就会收到如下正告:
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/<user>/<repo>/': The requested URL returned error: 403
解决方案就是应用拜访令牌(AccessToken)。如果 Git 客户端提醒你须要登录 Github,账户输出oauth2
,明码输出你的令牌。
如果你曾经用账户明码登录过了。在推送的时候,不会提醒你登录,而是间接报错。这种状况就须要关上 ~/.git-credentials
文件,这个是 Git 客户端贮存账号密码的中央。找到@github.com
,把后面的用户名明码替换成oauth2:<token>
,即功败垂成。
留神,如果你的用户名明码在你仓库的近程 URL 外面,同样须要用 git remote set-url
来替换掉。
其实所有 Git 服务端都能够这样操作,这样反对权限隔离和细粒度管制,防止一码通明码,更加平安。
正文完