gpt4 book ai didi

git - 在 Windows 上添加 Git 凭据

转载 作者:太空狗 更新时间:2023-10-29 12:50:31 25 4
gpt4 key购买 nike

我在 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 之后,我让它响应了我没有访问权限。有办法解决这个问题吗?

最佳答案

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

git config --global credential.helper manager-core

这是来自 Microsoft multi-platform credential manager GCM .

然后您的密码(或者现在的 token )将存储在 Windows 凭据管理器中。
在“Unable to change git account”中查看更多信息。

在第一次推送时,将出现一个 pop 窗口,要求您提供目标服务器(例如 github.com)的凭据(用户名/密码)

如果没有,那可能意味着您的凭据已经存储了。
如果它们不正确,一个简单的 printf "protocol=https\nhost=github.com\nusername=xxx"| git-credential-manager-core erase 将删除它们(在 Windows、Linux 或 Mac 上)


在 Git 2.29(2020 年第 4 季度)中,凭证协议(protocol)接收端的解析器被放宽,以允许凭证助手终止具有 CRLF 行结尾和 LF 行结尾的行。

参见 commit 356c473 (2020 年 10 月 3 日)作者:Nikita Leonov (nyckyta) .
(由 Junio C Hamano -- gitster -- merge 于 commit 542b3c2 ,2020 年 10 月 5 日)

credential: treat CR/LF as line endings in the credential protocol

Signed-off-by: Nikita Leonov
Signed-off-by: Johannes Schindelin

This fix makes using Git credentials more friendly to Windows users: it allows a credential helper to communicate using CR/LF line endings ("DOS line endings" commonly found on Windows) instead of LF-only line endings ("Unix line endings").

Note that this changes the behavior a bit: if a credential helper produces, say, a password with a trailing Carriage Return character, that will now be culled even when the rest of the lines end only in Line Feed characters, indicating that the Carriage Return was not meant to be part of the line ending.

In practice, it seems very unlikely that something like this happens. Passwords usually need to consist of non-control characters, URLs need to have special characters URL-encoded, and user names, well, are names.

However, it does help on Windows, where CR/LF line endings are common: as unrecognized commands are simply ignored by the credential machinery, even a command like quit\r (which is clearly intended to abort) would simply be ignored (silently) by Git.

So let's change the credential machinery to accept both CR/LF and LF line endings.

While we do this for the credential helper protocol, we do not adjust git credential-cache--daemon(man) (which won't work on Windows, anyway, because it requires Unix sockets) nor git credential-store(man) (which writes the file ~/.git-credentials which we consider an implementation detail that should be opaque to the user, read: we do expect users not to edit this file manually).

关于git - 在 Windows 上添加 Git 凭据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46878457/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com