1

I am using GitPython to clone git repositories on Github.com,

However the git.Repo.clone_from() is not working, and keep asking me the usename of Github.com

import git
git.Repo.clone_from("https://github.com/aligos/belajar-rust", "belajar-rust")

I found that this is caused by the git repository, it seems some repository requires Username and Password authenticated before cloning.

I wonder how to deal with the prompt?

Qoros
  • 493
  • 7
  • 16
  • 1
    See http://stackoverflow.com/q/6565357/1256452 - it's technically *neither* Git *nor* Python asking for user-name and password, but rather the helper program that Git uses to obtain authenticated `https` access to GitHub. You must authenticate to gain access, but you control the *method* of authentication (ssh or https) via the URL, and having chosen a method, the next level down is generally OS-specific. (See also http://stackoverflow.com/q/33343091/1256452 if you choose to use ssh.) – torek Mar 27 '17 at 23:59
  • @torek thanks for the hints. – Qoros Mar 28 '17 at 01:00
  • @torek As you illustrated, I have to get authenticated before cloning, but in my situation (downloading many git repositories), only few of them requesting Username and Password, I can download other repositories without inputting password. – Qoros Mar 28 '17 at 01:15
  • Yes, whether authentication is required (and who is allowed access) is per-GitHub-repository, as controlled by GitHub. (GitHub in turn set that based on each repository owner's request.) – torek Mar 28 '17 at 01:18
  • Thanks@torek, I understand now. – Qoros Mar 28 '17 at 01:42
  • See https://stackoverflow.com/questions/43520843/how-to-clone-from-specific-branch-from-git-using-gitpython, it's the same case as your's – Baini.Marouane May 12 '17 at 09:24
  • Does this answer your question? [How to clone from specific branch from Git using Gitpython](https://stackoverflow.com/questions/43520843/how-to-clone-from-specific-branch-from-git-using-gitpython) – bsplosion May 29 '20 at 18:31

0 Answers0