当我尝试使用 git pull
时,我的控制台上出现此错误:
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 "..." : The requested URL returned error: 403
这很奇怪,因为我只是在两周前按照文档在 GitHub 上创建了一个 token 。该 token 将于 2021 年 10 月 26 日星期二到期。为什么今天已将其删除?
最佳答案
从 2021 年 8 月 13 日起,GitHub 在对 Git 操作进行身份验证时不再接受帐户密码。您需要添加 PAT(个人访问 token )相反,您可以按照以下方法在您的系统上添加 PAT。
Create Personal Access Token on GitHub
From your GitHub account, go to Settings => Developer Settings => Personal Access Token => Generate New Token (Give your password) => Fillup the form => click Generate token => Copy the generated Token, it will be something like
ghp_sFhFsSHhTzMDreGRLjmks4Tzuzgthdvfsrta
现在根据您的机器遵循以下方法:
For Windows OS ⤴
Go to Credential Manager from Control Panel => Windows Credentials => find
git:https://github.com
=> Edit => On Password replace with with your GitHub Personal Access Token => You are DoneIf you don’t find
git:https://github.com
=> Click on Add a generic credential => Internet address will begit:https://github.com
and you need to type in your username and password will be your GitHub Personal Access Token => Click Ok and you are done
For macOS ⤴
Click on the Spotlight icon (magnifying glass) on the right side of the menu bar. Type Keychain access then press the Enter key to launch the app => In Keychain Access, search for
github.com
=> Find the internet password entry forgithub.com
=> Edit or delete the entry accordingly => You are done
For a Linux-based OS ⤴
For Linux, you need to configure the local GIT client with a username and email address,
$ git config --global user.name "your_github_username" $ git config --global user.email "your_github_email" $ git config -l
Once GIT is configured, we can begin using it to access GitHub. Example:
$ git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY > Cloning into `YOUR-REPOSITORY`... Username: <type your username> Password: <type your password or personal access token (GitHub)
Now cache the given record in your computer to remembers the token:
$ git config --global credential.helper cache
If needed, anytime you can delete the cache record by:
$ git config --global --unset credential.helper $ git config --system --unset credential.helper
Now try to pull with
-v
to verify$ git pull -v
Linux/Debian (Clone as follows):
git clone https://<tokenhere>@github.com/<user>/<repo>.git
For PhpStorm
If you are using PhpStorm, go to menu Git => pull and select authentication via Personal Access Token. Enter your
PAT
it will allow you to pull/push the changes.
关于git - 删除了对密码身份验证的支持。请改用个人访问 token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68783563/