在Windows上添加Git凭据

PJ *_*sky 9 git bash github

我在Windows 10系统上,正在尝试将我的凭据添加到Git Bash中的Git。我找不到存储密码的方法。

我检查了GitHub的文档,该文档说的只是输入这一行git config --global credential.helper wincred,但这似乎没有任何意义,因为没有提示输入密码。我检查了Git的文档,该文档说要使用command git credential-store --file ~/git.store store并填写所有提示。bash模拟器无法读取凭据。

最后,我尝试像通过添加电子邮件一样添加密码,git config --global user.password "5ecre7"但是在存储库上运行了示例git clone之后,我让它响应说我没有访问权限。有没有办法解决这个问题?

Von*_*onC 14

理想情况下,您应该输入:

git config --global credential.helper manager
Run Code Online (Sandbox Code Playgroud)

然后,您的密码将存储在Windows凭据管理器中。
请参阅“ 无法更改git帐户 ”中的更多信息。

  • 由于某种原因,删除凭据的命令对我来说挂起了。我在控制面板 -> 凭据管理器 -> Windows 凭据 -> 通用凭据中找到了凭据并将其删除。 (4认同)
  • @Enrico 您需要一个最新的 Windows 版 Git (https://github.com/git-for-windows/git/releases) 才能识别“credential-manager-core”。或者您需要在 Linux/Mac 上单独安装 https://github.com/microsoft/Git-Credential-Manager-Core。 (3认同)
  • “git:‘credential-manager-core’不是 git 命令。请参阅‘git --help’。” (2认同)

sai*_*009 12

抱歉,没有任何效果对我来说(使用 msys git 2.33.0),这是我的解决方案:

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

转到某个源目录

$ git add . && git commit -m "some commit" && git push origin master
Username for 'https://github.com': <type user name here>
Password for 'https://<typed user name>@github.com': <type generated token here>
Run Code Online (Sandbox Code Playgroud)


小智 8

我尝试了很多方法,但 Windows 凭据没有添加 Git 的凭据。然后我做了以下简单的操作,它解决了我的问题。

  • 我从 Windows 凭据管理器中删除了相关凭据。
  • 然后我从项目文件夹中打开 Git Bash。
  • 然后编写“git fetch origin”命令。
  • Git Bash 首先询问用户名,然后询问密码。

然后我检查了 Windows 凭据管理器...瞧!它现在显示一个类似于“git:http://username@address”的凭据

我尝试在配置文件中添加诸如“[credential] helper = manager/wincred”之类的内容,但在此解决方案之后不需要该部分,我删除了该 [credential] 部分。有人说这可能是因为你的 git 服务器没有使用 https。如果使用 https 可能您可以找到不同的解决方案。我的脸上仍然挂着傻乎乎的笑容