Git은 컴퓨터 파일의 변경 사항을 추적하는 분산 버전 관리 시스템으로, 일반적으로 소프트웨어 개발 중 소스 코드를 공동으로 개발하는 프로그래머들 간의 작업을 조율하는 데 사용됩니다.
이 노트북은 Git repository에서 텍스트 파일을 로드하는 방법을 보여줍니다.

디스크에서 기존 repository 로드하기

pip install -qU  GitPython
from git import Repo

repo = Repo.clone_from(
    "https://github.com/langchain-ai/langchain", to_path="./example_data/test_repo1"
)
branch = repo.head.reference
from langchain_community.document_loaders import GitLoader
loader = GitLoader(repo_path="./example_data/test_repo1/", branch=branch)
data = loader.load()
len(data)
print(data[0])
page_content='.venv\n.github\n.git\n.mypy_cache\n.pytest_cache\nDockerfile' metadata={'file_path': '.dockerignore', 'file_name': '.dockerignore', 'file_type': ''}

url에서 repository clone하기

from langchain_community.document_loaders import GitLoader
loader = GitLoader(
    clone_url="https://github.com/langchain-ai/langchain",
    repo_path="./example_data/test_repo2/",
    branch="master",
)
data = loader.load()
len(data)
1074

로드할 파일 필터링하기

from langchain_community.document_loaders import GitLoader

# e.g. loading only python files
loader = GitLoader(
    repo_path="./example_data/test_repo1/",
    file_filter=lambda file_path: file_path.endswith(".py"),
)

Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.
I