Search code examples
gitbashexpectazure-devops

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


Solution

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