相关疑难解决方法(0)

从GitHub存储个人访问令牌的位置?

在GitHub中生成个人访问令牌后,是否有必要将其存储在本地的某个位置?

如果是,是否有任何可以存储的首选方式?

git github access-token

30
推荐指数
8
解决办法
2万
查看次数

在 GitHub 上更新个人访问令牌 (PAT) 的命令行 Git credential.helper

我有几个存储库,显然我正在使用 GitHub 密码身份验证的缓存版本。我最近才了解到这一点,因为 GitHub 停止支持密码,而是需要个人访问令牌 (PAT) 或 SSH 密钥。

对于拉取或推送的所有私有存储库,我会收到以下消息:

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/villano-lab/CEvNS.git/': The requested URL returned error: 403
Run Code Online (Sandbox Code Playgroud)

我通过查看这篇文章解决了这个问题。根据该信息,我推断我应该检查我的参数credential.helper。通过做:

git config --list
Run Code Online (Sandbox Code Playgroud)

我发现它被设置为“存储”,如下所示:

credential.helper=store
Run Code Online (Sandbox Code Playgroud)

所以我所做的就是这样设置的:

git config credential.helper ""
Run Code Online (Sandbox Code Playgroud)

这样做的目的是让我再次输入我的用户名和密码(而不是由 git 客户端以默认方式提供)。然后,我能够创建 GitHub 个人访问令牌并在密码字段中使用它,并且满足新的 GitHub 要求,并且我没有收到错误。

问题是,我如何使其永久化?例如,如何将 PAT 放入 git 客户端缓存中,这样我就不必像以前一样再次输入它?截至目前,如果我回到:

git config credential.helper store
Run Code Online (Sandbox Code Playgroud)

它将恢复为旧密码,GitHub …

git github

11
推荐指数
1
解决办法
2万
查看次数

标签 统计

git ×2

github ×2

access-token ×1