git credential.helper 不存储用户名密码

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

我正在编写一个部署脚本,它克隆 git 存储库,然后执行其他任务,例如获取等。我已经运行了这个

git config --global credential.helper cache

克隆步骤的用户名和密码由expect脚本提供。 但这些详细信息没有按应有的方式缓存。脚本再次提示输入用户详细信息

我无法使用 ssh,因为我正在使用 Visual Studio Online

git bash expect azure-devops
4个回答
14
投票

您可以像这样创建一个文件

~/.netrc

machine github.com
login <username>
password <password>

Git 将使用它。另一种选择是 git-credential-store:

git config --global credential.helper store

凭证保存至

~/.git-credentials


13
投票

很旧的线程,但我今天找到了它,所以...

在告诉 git 在哪里存储凭证后,它在我的设置(Ubuntu 服务器 20.04 LTS)中起作用。 Ubuntu 中似乎没有默认设置:

$ git config --global credential.helper 'store --file ~/.my-credentials'

将其与以下组合:

$ git config --global credential.helper store

一切顺利。

来源:https://git-scm.com/book/en/v2/Git-Tools-Credential-Storage


3
投票

Ubuntu 20.04.3 LTS(bash):

$ git config --global credential.helper 'store --file ~/.my-credentials'

之后打开主目录中的

.gitconfig
并确保有:

[credential]
        helper = store --file ~/.my-credentials

现在只需推送一些内容,提供您的凭据,它们就会被保存到主目录中的

.my-credentials
文件中。


我不确定 Shoobdidoo 的意思:

将其与以下组合:

$ git config --global credential.helper store

但就我而言,在

git config --global credential.helper 'store --file ~/.my-credentials'
之后运行此命令会将
helper = store --file ~/.my-credentials
替换为
helper = store
,并且它将不起作用。


0
投票

Git 凭证助手只能与 git 1.7.10 或更高版本一起使用,如下所述:

https://help.github.com/articles/caching-your-github-password-in-git/

如果您使用旧版本,您仍然可以设置配置选项,但它不会执行任何操作。

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