[英]git credential.helper does not store username password
I am writing a deployment script which clones a git repo and then performs other tasks such as fetch etc .I have run this我正在编写一个部署脚本,它克隆一个 git repo,然后执行其他任务,例如 fetch 等。我已经运行了这个
git config --global credential.helper cache
The username and password for cloning step are provided by an expect script.克隆步骤的用户名和密码由期望脚本提供。 But these details are not cached as it should be.The script again prompts for user details但是这些详细信息并未按应有的方式缓存。脚本再次提示输入用户详细信息
I cannot use ssh as I am using Visual Studio Online我无法使用 ssh,因为我正在使用 Visual Studio Online
You can create a file ~/.netrc
like this:您可以像这样创建文件~/.netrc
:
machine github.com
login <username>
password <password>
and Git will use it. Git 会使用它。 Another option is git-credential-store :另一种选择是git-credential-store :
git config --global credential.helper store
Credentials are saved to ~/.git-credentials
.凭据保存到~/.git-credentials
。
Very old thread, but I found it today, so...很老的线程,但我今天找到了它,所以......
It worked in my setup (Ubuntu server 20.04 LTS) after telling git, where to store the credentials.在告诉 git 在哪里存储凭据后,它在我的设置(Ubuntu 服务器 20.04 LTS)中工作。 It seems, that there's no default for this in Ubuntu:看来,在 Ubuntu 中没有默认设置:
$ git config --global credential.helper 'store --file ~/.my-credentials'
by combining it with:通过将其与:
$ git config --global credential.helper store
everything worked.一切正常。
Source: https://git-scm.com/book/en/v2/Git-Tools-Credential-Storage来源: https ://git-scm.com/book/en/v2/Git-Tools-Credential-Storage
Ubuntu 20.04.3 LTS: Ubuntu 20.04.3 LTS:
git config --global credential.helper 'store --file ~/.my-credentials'
after that open .gitconfig
in your home directory and make sure there is:之后在你的主目录中打开.gitconfig
并确保有:
[credential]
helper = store --file ~/.my-credentials
now just simply push something, provide your credentials and they will be saved to .my-credentials
file in home directory.现在只需简单地推送一些东西,提供您的凭据,它们将被保存到主目录中的.my-credentials
文件中。
I'm not sure what Shoobdidoo means by:我不确定 Shobdidoo 的意思是:
by combining it with:通过将其与:
$ git config --global credential.helper store
but in my case running this after git config --global credential.helper 'store --file ~/.my-credentials'
will replace helper = store --file ~/.my-credentials
with helper = store
and it won't work.但在我的情况下,在git config --global credential.helper 'store --file ~/.my-credentials'
之后运行它会将helper = store --file ~/.my-credentials
替换为helper = store
并且它不会工作。
The Git credential helper can only be used with git 1.7.10 or newer as stated here: Git 凭证助手只能与 git 1.7.10 或更高版本一起使用,如下所述:
https://help.github.com/articles/caching-your-github-password-in-git/ https://help.github.com/articles/caching-your-github-password-in-git/
If you use an older version, you can still set the configuration option, but it doesn't do anything.如果您使用旧版本,您仍然可以设置配置选项,但它不会做任何事情。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.