In my old posts, I have always made rants about how cool and comfy Python is. Here’s a tiny code snippet that shows how I fetch remote Git repos with Python and the awesome GitPython library:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
import git, os, shutil DIR_NAME = "temp" REMOTE_URL = "https://github.com/hasinhayder/LightBulb.git" if os.path.isdir(DIR_NAME): shutil.rmtree(DIR_NAME) os.mkdir(DIR_NAME) repo = git.Repo.init(DIR_NAME) origin = repo.create_remote('origin',REMOTE_URL) origin.fetch() origin.pull(origin.refs[0].remote_head) print "---- DONE ----" |
PS: Installing GitPython is just a breeze on *Nix with:
|
1 |
sudo easy_install GitPython |