9

I need to do a git pull using https URL as an online command. this command I need to integrate in a bash script. But all the time it is asking the username and password.

The repository is in AWS code-commit

1
  • 1
    Read some ssh tutorial about public and private keys and use a git: URL for git commands Commented Oct 19, 2017 at 5:14

3 Answers 3

12

Try this:

git clone https://username:[email protected]/v1../repos../..

This way worked for me for CodeCommit (AWS) repository

Sign up to request clarification or add additional context in comments.

2 Comments

Note that this won't work if the password contains characters illegal for the shell currently used, like "/" and "\"
If your password contains characters illegal for the shell you can encode your password to URL (for example, @ will be %40 etc). You can see more here: stackoverflow.com/questions/22544219/…
4

Check this link: Enter user password in command

As is described perfectly in that post, you basically have three options:

  1. Store the password in .netrc file (with 600 permissions). Make sure you clone the repo specifying the username in the url.
  2. Clone the repo with https://user:pass@domain/repo . Take into account that your password will be visible in several places...
  3. Use the credential helper.

Comments

1

As an update, AWS has released their remote git remote codecommit. With proper IAM setup, you can do oneline pulls without even passing username and passwords. This is now the recommended method by AWS. It can be setup on your local or on a container that's running in an AWS Pipeline for example.

i.e. git clone codecommit://HelloWorldRepo myLocalHelloWorldRepo And then you can git pull as normal.

Full documentation is here: https://docs.aws.amazon.com/codecommit/latest/userguide/setting-up-git-remote-codecommit.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.