I wrote a small script that is a wrapper around git push. It modifies the
git remote url to insert username and password (read from
env). No need to store ssh keys on remote server or git clone with https credentials! If not credential are found, it throws an exception. You should only use it when you need to read the credentials from environment variables.
github.com repo, It looks for
GITHUB_USER first, then for
USER environment variable. Similarly it looks for
GIT_TOKEN for tokens. Fot
gitlab.com repo, it looks for
USER for username, and
GIT_TOKEN for password.
If the script can’t determine the username and password, it raises an exception.
Then it calls
git push on new url that has username and password. For example
git push https://github.com/dilawar/Scripts will become
git push https://dilawar:firstname.lastname@example.org/dilawar/Scritps.
You can download the script from here.
Permalink at the time of writing: https://github.com/dilawar/Scripts/blob/33e735c7c92f77ac69b464b0b99fab9ee2668b65/,git_push