GitLoader#

class langchain_community.document_loaders.git.GitLoader(repo_path: str, clone_url: str | None = None, branch: str | None = 'main', file_filter: Callable[[str], bool] | None = None)[source]#

Load Git repository files.

The Repository can be local on disk available at repo_path, or remote at clone_url that will be cloned to repo_path. Currently, supports only text files.

Each document represents one file in the repository. The path points to the local Git repository, and the branch specifies the branch to load files from. By default, it loads from the main branch.

Parameters:
  • repo_path (str) – The path to the Git repository.

  • clone_url (str | None) – Optional. The URL to clone the repository from.

  • branch (str | None) – Optional. The branch to load files from. Defaults to main.

  • file_filter (Callable[[str], bool] | None) – Optional. A function that takes a file path and returns a boolean indicating whether to load the file. Defaults to None.

Methods

__init__(repo_path[,Β clone_url,Β branch,Β ...])

alazy_load()

A lazy loader for Documents.

aload()

Load data into Document objects.

lazy_load()

A lazy loader for Documents.

load()

Load data into Document objects.

load_and_split([text_splitter])

Load Documents and split into chunks.

__init__(repo_path: str, clone_url: str | None = None, branch: str | None = 'main', file_filter: Callable[[str], bool] | None = None)[source]#
Parameters:
  • repo_path (str) – The path to the Git repository.

  • clone_url (str | None) – Optional. The URL to clone the repository from.

  • branch (str | None) – Optional. The branch to load files from. Defaults to main.

  • file_filter (Callable[[str], bool] | None) – Optional. A function that takes a file path and returns a boolean indicating whether to load the file. Defaults to None.

async alazy_load() β†’ AsyncIterator[Document]#

A lazy loader for Documents.

Return type:

AsyncIterator[Document]

async aload() β†’ list[Document]#

Load data into Document objects.

Return type:

list[Document]

lazy_load() β†’ Iterator[Document][source]#

A lazy loader for Documents.

Return type:

Iterator[Document]

load() β†’ list[Document]#

Load data into Document objects.

Return type:

list[Document]

load_and_split(text_splitter: TextSplitter | None = None) β†’ list[Document]#

Load Documents and split into chunks. Chunks are returned as Documents.

Do not override this method. It should be considered to be deprecated!

Parameters:

text_splitter (Optional[TextSplitter]) – TextSplitter instance to use for splitting documents. Defaults to RecursiveCharacterTextSplitter.

Returns:

List of Documents.

Return type:

list[Document]

Examples using GitLoader