Cloning a private repo using HTTPS with gitpython
<p>I am using gitpython to clone a git repository over HTTPS. If the project is a private repo, it will prompt for username and password. How do I interact with the prompt pythonically to pass username and password variables ?</p>

<pre><code>from git import Repo

HTTPS_REMOTE_URL = 'https://github.com/username/private-project'
DEST_NAME = 'https-cloned-private-project'
cloned_repo = Repo.clone_from(HTTPS_REMOTE_URL, DEST_NAME)
</code></pre>

<p>Output of running this code:</p>

<pre><code>$ python example.py
Username for 'https://github.com': example
Password for 'https://example@github.com': 
</code></pre>

<p>I know it's possible to include the username and password in the URL:</p>

<pre><code>HTTPS_REMOTE_URL = 'https://username:password@github.com/username/private-project'
</code></pre>

<p>However, I have no way of knowing ahead of time if this is a private repo. </p>