简体   繁体   English

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

[英]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.

相关问题 git credential.helper = cache永远不会忘记密码? - git credential.helper=cache never forgets the password? Git LFS 不考虑 credential.helper 的配置文件级别 - Git LFS does not respect level of config files for credential.helper Git - 仅在使用 git config credential.helper store 后才找到存储库 - Git - repository not found only after using git config credential.helper store Windows 10上的Git - credential.helper搞砸了 - Git on Windows 10 - credential.helper messed up git - credential.helper 在脚本中运行时不起作用 - git - credential.helper not working when run in a script 我是否应该删除 credential.helper=store 或 credential.helper=manager 以避免每次都输入我的凭据? - Should I delete either credential.helper=store or credential.helper=manager to avoid to type in my credentials every time? git:osxkeychain凭证助手无声地记住用户名/密码 - git: osxkeychain credential helper silently fails to remember username/password git 凭证缓存与 `git config --global credential.helper 'cache` 的安全性如何? - How secure is git credential caching with `git config --global credential.helper 'cache`? Git 凭证助手 - 更新密码 - Git credential helper - update password 尽管Wincred作为credential.helper和_netrc文件,TortoiseGit仍在询问密码 - TortoiseGit is still asking password despite having wincred as credential.helper and _netrc file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM