如何配置Cygwin git进行双因素身份验证,请访问github.com?

wljmcqd8  于 2023-02-07  发布在  Git
关注(0)|答案(2)|浏览(160)

我是一个git新手,我在www.example.com上建立了一个双重认证账户。github.com with two-factor authentication.
我可以很好地使用它与MINGW32 bash shell ,但我试图使用它与Cygwin。
这是我得到的:

dave@ENOUGH /cygdrive/u/testG
$ git clone  https://github.com/nerdfever/<project>
Cloning into '<project>'...
Username for 'https://github.com':
Password for 'https://Nerdfever@github.com':
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/nerdfever/<project>/'

我确实在Cygwin git中设置了www.example.com和www.example.com配置。 user.name and user.email configs in Cygwin git.
我需要做什么才能让它工作?

myzjeezk

myzjeezk1#

我不知道为什么有人投我的票,但不管怎样,我明白了:

Git under Cygwin:
a) Install git from Cygwin setup.exe
b) git config --global user.name "<username>"
c) git config --global user.password "<password>"
d) git config --global credential.helper store
e) Get personal access token per https://help.github.com/articles/creating-an-access-token-for-command-line-use/
f) git clone <project>; first time it'll ask for credentials, after that it will store them

注意当git询问你的密码时,给予它你的个人访问令牌(不是你的密码)。

8dtrkrch

8dtrkrch2#

当我更改GitHub的密码时,我遇到了类似的情况。上面提供的答案很好用,但选项:

git config --global credential.helper store

导致git将登录名和密码数据以纯文本形式存储在主目录的文件中

~/.git-credentials

下面是如何在Cygwin git How to make Git-Credential-Manager-for-Windows works with Cygwin?中使用Windows版Git凭据管理器的说明
希望这个有用。
当您配置此功能时,您可以在控制面板〉凭据管理器中更新您的密码,如下图所示:

相关问题