Git:每当我尝试推送时都会出现 CredentialHelperSelector

问题描述 投票:0回答:1

我有一个已有 2 年历史的存储库。所有文件都没有被推送,原因我不记得了。我将其复制到另一个外部驱动器,因为我必须格式化机器,然后再转移到其他东西。最近我买了一台新笔记本电脑并将存储库复制到这台机器中。

我遇到的第一个问题与“所有权”有关。我发现当我使用

whoami /user
时,我与创建此存储库并将其初始提交推送到 GitHub 时机器上的用户没有什么不同。我最终使用
takeown /f repo_dir /r /d y
命令解决了这个问题。否则,即使
git status
也无法在此存储库中运行。

现在我可以将代码提交到此存储库并将其添加到 SourceTree。但我做不到

git push
!遥控器位于 GitHub 上。我使用的是 GitHub 的免费版本,这已经足够了。每次我尝试使用终端或 SourceTree GUI 进行推送时,我都会得到以下信息:

enter image description here

我不记得两岁时我是如何设置的。但我可以登录该存储库所在的 GitHub。问题是,今天我需要做什么才能获得能够推送到此远程的凭据?我相信它与 SSH 或 HTTPS 有关,但已不记得详细信息了。我从这个弹出窗口中选择了很多选项,但它又回来了。我相信我必须在 Git 的某个配置文件中的某个地方更改一些内容,但不确定这是否真的是解决这个问题的方法!也许我需要删除 Windows 凭据管理器中的所有内容,以便 Git 会尝试从头开始获取它们,我不确定。

如果有人能给我一些指导,我将不胜感激。

git
1个回答
0
投票

好吧,我确实意识到 Git 为 Git 引入了某种凭证管理器,以使 Git 存储库更加安全。此 Git 凭据管理器现在随 Git 一起提供,可以在计算机上安装 Git 时安装。我确认我拥有它,因为

git-credential-manager
在我的机器上被接受。它打印了这个:

$ git-credential-manager
Required command was not provided.

git-credential-manager

Usage:
  git-credential-manager [options] [command]

Options:
  --version       Show version information
  -?, -h, --help  Show help and usage information

Commands:
  get          [Git] Return a stored credential
  store        [Git] Store a credential
  erase        [Git] Erase a stored credential
  configure    Configure Git Credential Manager as the Git credential helper
  unconfigure  Unconfigure Git Credential Manager as the Git credential helper
  diagnose     Run diagnostics and gather logs to diagnose problems with Git Credential Manager
  azure-repos  Commands for interacting with the Azure Repos host provider

然后我执行了这两个命令:

gyu@DESKTOP-TOOMUCHTROUBLE /cygdrive/e/My_Designs/FPGA/jpeg_encoder
$ git-credential-manager configure
Configuring component 'Git Credential Manager'...
Configuring component 'Azure Repos provider'...

gyu@DESKTOP-TOOMUCHTROUBLE /cygdrive/e/My_Designs/FPGA/jpeg_encoder
$ git-credential-manager diagnose
Running diagnostics...

 [ OK ] Environment
 [ OK ] File system
 [ OK ] Networking
 [ OK ] Git
 [ OK ] Credential storage
 [ OK ] Microsoft authentication (AAD/MSA)
 [ OK ] GitHub API

Diagnostic summary: 7 passed, 0 skipped, 0 failed.
Log files:
  E:\My_Designs\FPGA\jpeg_encoder\gcm-diagnose.log

Caution: Log files may include sensitive information - redact before sharing.

我在 SourceTree 和 Cygwin 中打开了这个内部终端。我使用 Cygwin 代替 WSL、PowerShell 和 CMD。现在,我可以从源代码树推送代码,也可以通过在终端中输入

git push
来推送代码。问题解决了。

© www.soinside.com 2019 - 2024. All rights reserved.