0

Need to execute git clone command from shell script

I tried to use the git clone command and it is working

I am able to execute the below command from the git-bash console to checkout the developer1_branch from my project

git clone --branch developer1_branch https://project_ip/project.git /tmp/$(date +%Y%m%d)

This command will ask for credentials and it will clone the project to /tmp folder with today's date.

Expected results:

  1. Need to run the same command from the shell script.
  2. To automate the script to read the credentials from a creds.properties file which will have user=userid & password=Password123 as properties? Please let me know how this can be achieved?
phd
  • 82,685
  • 13
  • 120
  • 165
send2kvd
  • 1
  • 4
  • It is unclear what you're asking. It seems you want to automate the clone execution or "save" the passwords, for that I would recommend using ssh for cloning the project instead. https://flaviocopes.com/how-to-setup-git-ssh-keys/ – Marc Sances May 02 '19 at 08:28
  • 1
    Check https://stackoverflow.com/questions/34099843/git-clone-without-asking-for-users-password – lojza May 02 '19 at 10:56
  • Possible duplicate of [Is there a way to cache GitHub credentials for pushing commits?](https://stackoverflow.com/questions/5343068/is-there-a-way-to-cache-github-credentials-for-pushing-commits) – phd May 02 '19 at 11:38
  • https://stackoverflow.com/search?q=%5Bgit-clone%5D+password+script – phd May 02 '19 at 11:38
  • 1
    You can specify `user:password` in the `https://` URL. Or you can use `~/.netrc` with `git-credential-netrc`. Or you can switch the protocol to `ssh://` and use ssh keys. – phd May 02 '19 at 11:40

0 Answers0