Search code examples
gitpython

Add a submodule with Gitpython


How can I add a submodule with Gitpython? I know how I add it the normal way but I do not find any help in the docs from Gitpython how I can add it with the lib.

many thanks


Solution

  • You can refer to Gitpython API, As it said, you can do:

    from git import Repo, Submodule
    
    repo = Repo(ROOT_REPO_PATH)
    
    Submodule.add(repo, SUBMODULE_NAME, SUBMODULE_PATH, SUBMODULE_URL)