最近在部署博客的过程中,收到了不在提供密码认证的邮件,内容如下,需要解决。
1 | Hi @sjtu-xx, |
根据邮件中的链接说明,需要使用令牌进行认证。
使用Mac搜索“keychain”并打开钥匙串,
搜索GitHub。您可能会看到两个选项:应用程序密码和互联网密码
打开应用程序密码。您可以选中“显示密码”框,并可能看到这仍然使用您的密码,而不是令牌。
- 清除之前的登陆信息
取消设置登录凭据。将此复制到您的终端,然后点击两次回车
1
2
3
4
5
6
7git config --global --unset user.name
git config --global --unset user.email
git config --global --unset credential.helper
git credential-osxkeychain erase
host=github.com
protocol=https
# Hit return/enter twice步骤2
打开一个新的终端窗口,并设置您的姓名和电子邮件:
1 | git config --global user.name "Your Name" |
- 步骤3
1 | Make a small local change to one of your repositories and git add ., then git commit -m "Your small change", then finally git push and you'll be asked for your GitHub username, in that field enter the email address for your GitHub account. |
在下一行中,系统会要求您提供密码,请在此处粘贴令牌(即从您创建令牌的GitHub复制并粘贴到其中),就像这样:
1 | git push |
您的提交将推送,您现在使用的是令牌身份验证,而不是密码身份验证。仅此而已。