Can I store git credentials in environment variables?

I would like to create a very simple shell script that will eventually be called by another application that updates the local git repository:

#!/bin/bash

cd $1
sudo git pull

When doing this, I am prompted for credentials (I exit the private BitBucket repository).

Is it possible (briefly) to store credentials in environment variables?

#!/bin/bash

export  GIT_USERNAME=<user>
export  GIT_PASSWORD=<pass>

cd $1
sudo git pull

The above does not work. Something? I could programmatically change the source url, but that seems a bit excellent.

+5
source share
2 answers

Git does not use credentials, it relies on the transport used.

0
source

, , HTTP, :

git config credential.helper '!f() { sleep 1; echo "username=${GIT_USER}\npassword=${GIT_PASSWORD}"; }; f'

UPDATE: sleep 1 . - . , Debian Jessie. , . sleep. - . strace, , . . strace git .

+10

All Articles