Fix Python – Python way to clone a git repository

Question

Asked By – Mike

Is there a Python way without using a subprocess to clone a git repository? I’m up for using any sort of modules you recommend.

Now we will see solution for issue: Python way to clone a git repository


Answer

There is GitPython. Haven’t heard of it before and internally, it relies on having the git executables somewhere; additionally, they might have plenty of bugs. But it could be worth a try.

How to clone:

import git
git.Git("/your/directory/to/clone").clone("git://gitorious.org/git-python/mainline.git")

(It’s not nice and I don’t know if it is the supported way to do it, but it worked.)

This question is answered By – Debilski

This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0