Submodules

A submodule is a foreign repository that is embedded within a dedicated subdirectory of the repositories tree.

class pygit2.Repository(path=None, flags=0)
add_submodule(url, path, link=True, callbacks=None)

Add a submodule to the index.

Returns: the submodule that was added.

Parameters:

url

The URL of the submdoule.

path

The path within the parent repository to add the submodule

link

Should workdir contain a gitlink to the repo in .git/modules vs. repo directly in workdir.

init_submodules(submodules: list[Submodule] = None, overwrite=False)

Initialize all submodules in repository. submodules: List of submodules to initialize. Default argument initializes all submodules. overwrite: Flag indicating if initialization should overwrite submodule entries.

listall_submodules() list[str]

Return a list with all submodule paths in the repository.

lookup_submodule(path)

Look up submodule information by name or path.

update_submodules(submodules=None, init=False, callbacks=None)

Update a submodule. This will clone a missing submodule and checkout the subrepository to the commit specified in the index of the containing repository. If the submodule repository doesn’t contain the target commit (e.g. because fetchRecurseSubmodules isn’t set), then the submodule is fetched using the fetch options supplied in options.

The Submodule type

Submodule.open()

Open the repository for a submodule.

Submodule.name

Name of the submodule.

Submodule.path

Path of the submodule.

Submodule.url

URL of the submodule.

Submodule.branch

Branch that is to be tracked by the submodule.

Submodule.head_id

Head of the submodule.