From a Bash script I would like to supply a password. I have tried the following:
echo 'mypass' | git pull
git pull < 'mypass'
git pull < echo 'mypass'
None seem to work.
username and password. We can supply the username and password along with the git clone command in the remote repository url itself. The syntax of the git clone command with the http protocol is, git clone http[s]://host. xz[:port]/path/to/repo.
There are three main approaches you can take: Using a personal authentication token or password. Using an SSH key. Using your GitHub password with 2-factor authentication.
Create file git_password.sh
with content:
#!/bin/sh
exec echo "$GIT_PASSWORD"
Assign your password to the GIT_PASSWORD environment variable
$ GIT_PASSWORD=your_password
Execute git command with GIT_ASKPASS environment variable. It will force password prompt and execute git_password.sh as callback:
$ GIT_ASKPASS=./git_password.sh git clone $REPO
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With