from git import Repo import os dirfile = os.path.abspath('d:/git/test') repo = Repo(dirfile) g = repo.git while True: try: g.pull() except Exception as e: print(e) else: print("Successful pull!") break