github身份验证令牌在Windows上存储在哪里?

时间:2019-10-07 03:48:18

标签: windows git github

如果我在专用存储库上运行类似于以下命令的命令:

git ls-remote https://github.com/org/repo.git

我收到以下提示。

enter image description here

我正在使用https://gitforwindows.org并查看Process Explorer,看来生成此窗口的可执行文件相对于Git for Windows安装文件夹是\mingw64\libexec\git-core\git-credential-manager.exe

输入凭据时,我从Github收到一封电子邮件,说创建了新的身份验证令牌。

此令牌存储在我的PC上的什么位置?当我重复上面的命令时,只要不再取消github网站上的令牌,便不再收到提示。

2 个答案:

答案 0 :(得分:2)

默认情况下,Git将使用Windows Credential Manager来通过Github for Windows桌面存储和检索Git凭据。

  

凭据管理器使您可以查看和删除保存的凭据,以登录网站,连接的应用程序和网络。

     

要打开凭据管理器,请在任务栏上的搜索框中键入凭据管理器,然后选择凭据管理器控制面板。   选择 Web凭据 Windows凭据以访问您要管理的凭据。

您将在 Windows凭据选项卡上找到GitHub - https://api.github.com/{username}条目。

答案 1 :(得分:1)

迈克·麦金托什(Mike Mackintosh)是对的。这是访问令牌的方法。

Install-Module CredentialManager -Scope AllUsers -Force

根据您的喜好更改上述命令上的标志。然后:

Get-StoredCredential -AsCredentialObject | %{$_} `
  | ?{ $_.targetName -like "*github.com*"} `
  | sort LastWritten `
  | select LastWritten,Targetname,Password

这将为您提供您可能已创建的令牌的列表。使用Get-Command -Module CredentialManager列出模块上所有可用的命令,您可以用来操纵凭据存储。