iamads
iamads

Reputation: 318

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 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

Upvotes: 13

Views: 17009

Answers (4)

zebra-f
zebra-f

Reputation: 150

Ubuntu 20.04.3 LTS (bash):

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

after that open .gitconfig in your home directory and make sure there is:

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


I'm not sure what Shoobdidoo means by:

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.

Upvotes: 3

Zombo
Zombo

Reputation: 1

You can create a file ~/.netrc like this:

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

and Git will use it. Another option is git-credential-store:

git config --global credential.helper store

Credentials are saved to ~/.git-credentials.

Upvotes: 15

Shoobdidoo
Shoobdidoo

Reputation: 131

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. It seems, that there's no default for this in 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

Upvotes: 13

Jesuisme
Jesuisme

Reputation: 1911

The Git credential helper can only be used with git 1.7.10 or newer as stated here:

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.

Upvotes: 0

Related Questions