Search code examples
pythongitgitpython

GitPython equivalent command


I need a GitPython equivalent command or commands of this git clone -b <branch_name> --recursive <url>. I hope the subprocess call is not the only way to do this. If anybody have an idea please let me know.


Solution

  • clone(path, progress=None, **kwargs) accepts kwargs which are passed on to the call of git clone:

    • odbt = ObjectDatabase Type, allowing to determine the object database implementation used by the returned Repo instance
    • All remaining keyword arguments are given to the git-clone command

    So you just add the options to your call to clone:

    repo.clone(path, b=branch_name, recursive=url)