如何在Windows上存储Git的身份验证凭据?

时间:2018-04-01 22:47:44

标签: windows git github

我尝试使用这个答案,但它没有用。 https://stackoverflow.com/a/5343146/148844

C:\Users\Chloe\workspace\catalyst_research>git --version
git version 2.15.1.windows.2

C:\Users\Chloe\workspace\catalyst_research>git config --global credential.helper manager

C:\Users\Chloe\workspace\catalyst_research>git pull

此时会弹出一个GUI对话框。

fatal: HttpRequestException encountered.
   An error occurred while sending the request.
fatal: HttpRequestException encountered.
   An error occurred while sending the request.
Username for 'https://github.com': email@domain.com
Password for 'https://email@domain.com@github.com':
remote: Counting objects: 10, done.
...
 2 files changed, 11 insertions(+), 5 deletions(-)

C:\Users\Chloe\workspace\catalyst_research>git config --global credential.helper "cache --timeout=2592000"

C:\Users\Chloe\workspace\catalyst_research>git pull
fatal: HttpRequestException encountered.
   An error occurred while sending the request.
git: 'credential-cache' is not a git command. See 'git --help'.
Username for 'https://github.com': email@domain.com
Password for 'https://email@domain.com@github.com':
git: 'credential-cache' is not a git command. See 'git --help'.
Already up to date.

C:\Users\Chloe\workspace\catalyst_research>git pull
fatal: HttpRequestException encountered.
   An error occurred while sending the request.
git: 'credential-cache' is not a git command. See 'git --help'.
Username for 'https://github.com': ^C

2 个答案:

答案 0 :(得分:1)

首先,将经理保留为凭证助手:

git config --global credential.helper manager

其次,当弹出窗口显示时,输入您的GitHub帐户用户名/密码。

然后,后续的Git命令不会再次要求您提供凭据。

如果您的凭据确实与https://github.com正确关联,则可以检查Windows Credential Manager

Username for 'https://github.com': email@domain.com

注意:您的GitHub用户名应该是您的GitHub帐户用户名,不是 email@domain.com

答案 1 :(得分:1)

我将Git升级到2.16.3版本并且运行良好。

chocolatey upgrade git