Search code examples
linuxgitbashgit-stashgit-config

Store credentials for git commands using HTTP


I would like to store Git credentials for git pulls permenantly on a linux machine, and git credential.helper doesn't work ( I think because I'm not using SSH ) - I get that error "Fatal: could not read password for 'http://....': No such device or address". Given that I'm not the administrator of the repository and only HTTP is allowed for authentication, and fortunately I don't care about the safety of the password. What can I do to put the git pull command in a bash file and avoid prompting the user for password?

I hope there is a way around it.


Solution

  • I'm assuming that your repository requires authentication for pulls, or else git wouldn't ask you for a password for the pull.

    The recommended way to bypass the user password prompt is to create an SSH key on that machine, add the public key to the git server, then use the SSH url for the remote instead of the HTTP/S url. But since you specifically said:

    I don't care about the safety of the password

    you can actually just specify the password inline for the git pull like this:

    git pull http://username:password@mygithost.com/my/repository