1

I have a batch file that will open a application git-cmd. When trying to clone a git repository, i'm getting prompt to enter password on the git-cmd. I want to do it all from the batch file. Is there a command from the batch file that will enter the password automatically to the gmd-cmd and not the windows cmd?

Here's my git connection on git-cmd: git clone username@git.hostname.com/file.git

  • you can use git clone ssh://${gitUser}@${gitIP}:${gitPort}/${gitDir} ./ with a RSA key to prevent password check, i ve done a script for my bro to manage git trought bash, maybe it can help you https://github.com/Fro99666/BASH_froggLinuxGitManager and for the RSA key check here : https://github.com/Fro99666/BASH_froggLinuxInstallRsaKey – Froggiz Sep 01 '15 at 16:02
  • @Froggiz i'm still getting prompt with password. – TheNewGuyOnTheRock Sep 01 '15 at 16:08
  • if you use RSA key you should not have a prompt, i am using it without, maybe you need more info about rsa/public key ? – Froggiz Sep 01 '15 at 16:15
  • is there a way without rsa/public key? – TheNewGuyOnTheRock Sep 01 '15 at 16:17

1 Answers1

1

If you are using https to clone your repository you can put your username and password in URL like this:

git clone https://username:password@git.hostname.com/file.git

However this is a security issue as you expose your password, so be careful.

Check also this topic to get more detailed answers

Community
  • 1
  • 1
Kacper Dziubek
  • 1,513
  • 1
  • 11
  • 16
  • This would be better suited as a comment. I understand your rep isn't high enough to do so but if you flesh out your answer with more information that actually answers the question, that would justify this answer. – ScottMcGready Sep 01 '15 at 16:09
  • does all git have https urls or does it have to be setup ? – TheNewGuyOnTheRock Sep 01 '15 at 16:09
  • @kacperd i'm getting error SSL Certificate problem: self signed certificate – TheNewGuyOnTheRock Sep 01 '15 at 16:13
  • You should check if your git server is over https or http and use the same. protocol in your clone url. – Kacper Dziubek Sep 01 '15 at 16:16
  • You cant try to omit SSL certificate check by changing git config so your clone command can look like: git -c http.sslVerify=false clone https://username:password@git.hostname.com/file.git – Kacper Dziubek Sep 01 '15 at 17:20
  • @kacperd is there anyway to make a script call from a batch file to input into the git-cmd so that when prompt to enter password the batch file can just input that for the value? – TheNewGuyOnTheRock Sep 01 '15 at 17:44