langchain_community.document_loaders.git.GitLoader¶

class langchain_community.document_loaders.git.GitLoader(repo_path: str, clone_url: Optional[str] = None, branch: Optional[str] = 'main', file_filter: Optional[Callable[[str], bool]] = 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 – The path to the Git repository.

  • clone_url – Optional. The URL to clone the repository from.

  • branch – Optional. The branch to load files from. Defaults to main.

  • file_filter – 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, ...])

param repo_path

The path to the Git repository.

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: Optional[str] = None, branch: Optional[str] = 'main', file_filter: Optional[Callable[[str], bool]] = None)[source]¶
Parameters
  • repo_path – The path to the Git repository.

  • clone_url – Optional. The URL to clone the repository from.

  • branch – Optional. The branch to load files from. Defaults to main.

  • file_filter – Optional. A function that takes a file path and returns a boolean indicating whether to load the file. Defaults to None.

lazy_load() Iterator[Document]¶

A lazy loader for Documents.

load() List[Document][source]¶

Load data into Document objects.

load_and_split(text_splitter: Optional[TextSplitter] = None) List[Document]¶

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

Parameters

text_splitter – TextSplitter instance to use for splitting documents. Defaults to RecursiveCharacterTextSplitter.

Returns

List of Documents.

Examples using GitLoader¶