Github使用新的token认证机制导致push失败问题解决

Github push推东西的时候突然报错了,一查发现是换了认证方式的原因,之前输入密码push,现在得改用token了,但是网上重置仓库密码啥的试了push都还是失败。

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/anzhihe/Efficient-office.git/': The requested URL returned error: 403

github通知如下:

Git password authentication is shutting down

As previously announced, starting on August 13, 2021, at 09:00 PST, we will no longer accept account passwords when authenticating Git operations on GitHub.com. Instead, token-based authentication (for example, personal access, OAuth, SSH Key, or GitHub App installation token) will be required for all authenticated Git operations.

Please refer to this blog post for instructions on what you need to do to continue using git operations securely.

Removal

  • August 13, 2021, at 09:00 PST

解决方法如下:

  1. 创建个人访问token,Creating a personal access token

  2. 更改认证方式,Caching your GitHub credentials in Git,以我用的MacOS为例

  1. ⑴.Install Git using Homebrew:

    $ brew install git
  2. ⑵.Install GCM Core using Homebrew:

    $ brew tap microsoft/git
    $ brew install --cask git-credential-manager-core

    For MacOS, you don't need to run git config because GCM Core automatically configures Git for you.

安装好pkg再push的话就会弹出一个认证框,选择token登陆,输入生成的token就ok啦,世界终于又归于清静了~!

手动操作方法:

方法一:重新git clone项目
方法二:执行git config --local credential.helper "",然后git push输入密码的时候输入token代替
方法三:执行git config --global --unset credential.helper,然后git push输入用户名和token,打开家目录下的隐藏文件.git-credentials,将新生成的token替换旧密码保存,再执行git config --global credential.helper store即可


参考:

anzhihe 安志合个人博客,版权所有 丨 如未注明,均为原创 丨 转载请注明转自:https://chegva.com/4650.html | ☆★★每天进步一点点,加油!★★☆ | 

您可能还感兴趣的文章!

发表评论

电子邮件地址不会被公开。 必填项已用*标注