I am new to Git.I want to clone my remote github repository (git://github.com/eltejaee/BIC2.git) with python script.I know that "dulwich" and "gitpython" are suitable but I couldn't clone or pull with them .What is the best python code to clone my remote github repository?
3 Answers
There are several modules you can use git-python or pygit
If you just want to clone/pull then you can use system commands:
os.system("git clone ...")
os.system("git pull")
and if you want the output of the command as well I recommend you to use subprocesses
For Github you can use python-github
Comments
My solution is very simple and straight forward. It doesn't even need the manual entry of paraphrase/password.
Here is my complete code:
import os
import sys
path = "/path/to/store/your/cloned/project"
clone = "git://github.com/eltejaee/BIC2.git"
os.system("sshpass -p your_password ssh user_name@your_lhost")
os.chdir(path) # Specifying the path where the cloned project has to be copied
os.system(clone) # Cloning
print "\n CLONED SUCCESSFULLY.! \n"