23 C
Bangalore
December 8, 2018
Untitled

Automate Git Clone Operations Using Python

import git, os, shutil

DIR_NAME = "myrepo"
GIT_URL = "https://github.com/rmccue/test-repository.git"

if os.path.isdir(DIR_NAME):
shutil.rmtree(DIR_NAME)

repo = git.Repo.init(DIR_NAME)
origin = repo.create_remote('origin',GIT_URL)
origin.fetch()
origin.pull(origin.refs[0].remote_head)
print "Repo Creation Completed"

Related posts

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.