-
-
Save salanisor/75b8fcb7a6b683e436c217610d2a79ba to your computer and use it in GitHub Desktop.
GitPython Library clone code from remote and switch branch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import git,os,shutil | |
def get_branch(url,path,branch): | |
if url == None or path == None: | |
raise ValueError("Please assign right URL and Path") | |
else: | |
if os.path.isdir(path): | |
shutil.rmtree(path) | |
os.mkdir(path) | |
repo = git.Repo.clone_from(url, path, progress=None) | |
git_ = repo.git | |
git_.checkout(branch) | |
git_.pull("--rebase") | |
print git_.status() | |
DIR_FOLDER = "/Users/david/Desktop/MultiscreenClient" | |
URL = "ssh://[email protected]:29418/IPTV/MultiscreenClient" | |
if __name__ == '__main__': | |
get_branch(URL,DIR_FOLDER,"b_R15CP4") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment