I want to write a program which will clone remote git repository and then do bunch of other stuff. The problem is that 'git clone' asks for password. It does not work when I open pipes to stdin/out/err to 'git clone' because it runs git-remote-http underneath which prompts for password on TTY.
I would like to pass the password from my program. I am using Python and Popen from subprocess. Code below does not wotk.
Popen(['git', 'clone', 'https://my.git.repo/repo.git'], shell=False, stdin=PIPE, stdout=PIPE, stderr=PIPE)
How can I achieve this?
If you do not want to use challenge authentication as the commenter said, I would use pexpect to automate this kind of interaction
You can git clone https://foo:[email protected]/repo.git
to get the data, and git remote set-url origin https://my.git.repo/repo.git
afterwards to clear the password. But you have an race-condition between the start of the clone, and the URL-change.
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