Last translated: 25 Jun 2025

Translation Not Available Yet

This repository's README hasn't been translated yet. Once translated, it will be easier to read and understand in your native language (中文).

After translating, add the links to README so others can view it directly.

Gitingest

图片

许可证 PyPI版本 GitHub星标 下载量

Discord

将任意 Git 代码库转换为适合大语言模型(LLM)提示的文本摘要。

您也可以将 GitHub URL 中的 hub 替换为 ingest 来获取对应摘要。

gitingest.com · Chrome扩展 · Firefox插件

Deutsch | Español | Français | 日本語 | 한국어 | Português | Русский | 中文

🚀 功能特性

  • 便捷代码上下文:通过 Git 仓库 URL 或本地目录获取文本摘要
  • 智能格式化:针对 LLM 提示优化的输出格式
  • 统计信息
    • 文件与目录结构
    • 摘要内容大小
    • 令牌数量统计
  • 命令行工具:可作为 shell 命令运行
  • Python 包:可在代码中直接导入使用

📚 系统要求

📦 安装指南

Gitingest 已发布至 PyPI。 可通过 pip 安装:

pip install gitingest

建议使用 pipx 进行安装。 可通过您常用的包管理器安装 pipx

brew install pipx
apt install pipx
scoop install pipx
...

首次使用 pipx 时需运行:

pipx ensurepath
# install gitingest
pipx install gitingest

🧩 浏览器扩展使用

Chrome 应用商店有售 获取 Firefox 插件 Edge 插件商店下载

扩展开源地址:lcandy2/gitingest-extension

欢迎提交问题与功能需求至该仓库。

💡 命令行使用

gitingest 命令行工具可分析代码库并生成文本摘要。

# Basic usage (writes to digest.txt by default)
gitingest /path/to/directory

# From URL
gitingest https://github.com/cyclotruc/gitingest

# or from specific subdirectory
gitingest https://github.com/cyclotruc/gitingest/tree/main/src/gitingest/utils

对于私有仓库,使用 --token/-t 参数:

# Get your token from https://github.com/settings/personal-access-tokens
gitingest https://github.com/username/private-repo --token github_pat_...

# Or set it as an environment variable
export GITHUB_TOKEN=github_pat_...
gitingest https://github.com/username/private-repo

默认会跳过 .gitignore 中列出的文件。如需包含这些文件,请使用 --include-gitignored 参数。

默认情况下,摘要会输出到当前工作目录的 digest.txt 文件。可通过两种方式自定义输出:

  • 使用 --output/-o <文件名> 指定输出文件
  • 使用 --output/-o - 直接输出到标准输出(便于管道操作)

查看完整选项与使用说明:

gitingest --help

🐍 Python 包使用

# Synchronous usage
from gitingest import ingest

summary, tree, content = ingest("path/to/directory")

# or from URL
summary, tree, content = ingest("https://github.com/cyclotruc/gitingest")

# or from a specific subdirectory
summary, tree, content = ingest("https://github.com/cyclotruc/gitingest/tree/main/src/gitingest/utils")

对于私有仓库,可传入令牌:

# Using token parameter
summary, tree, content = ingest("https://github.com/username/private-repo", token="github_pat_...")

# Or set it as an environment variable
import os
os.environ["GITHUB_TOKEN"] = "github_pat_..."
summary, tree, content = ingest("https://github.com/username/private-repo")

默认不会写入文件,可通过 output 参数启用。

# Asynchronous usage
from gitingest import ingest_async
import asyncio

result = asyncio.run(ingest_async("path/to/directory"))

Jupyter notebook 使用

from gitingest import ingest_async

# Use await directly in Jupyter
summary, tree, content = await ingest_async("path/to/directory")

这是因为 Jupyter notebook 默认采用异步模式。

🐳 自托管部署

  1. 构建镜像:

    docker build -t gitingest .
    
  2. 运行容器:

    docker run -d --name gitingest -p 8000:8000 gitingest
    

应用将运行于 http://localhost:8000

如需绑定域名,可通过环境变量 ALLOWED_HOSTS 指定允许的域名。

   # Default: "gitingest.com, *.gitingest.com, localhost, 127.0.0.1".
   ALLOWED_HOSTS="example.com, localhost, 127.0.0.1"

🤝 参与贡献

非技术贡献方式

  • 提交问题:发现错误或有新功能想法时,请在 GitHub 上创建 issue,帮助我们跟踪处理
  • 分享推荐:如果您喜欢 Gitingest,请推荐给朋友、同事或在社交媒体分享,助力社区成长
  • 实际使用:最宝贵的反馈来自真实使用场景!遇到任何问题或有改进建议,欢迎在 GitHub 创建 issue 或通过 Discord 联系我们

技术贡献方式

Gitingest 对首次贡献者友好,采用简洁的 Python 和 HTML 代码架构。开发过程中如需帮助,请通过 Discord 联系我们。提交 PR 的详细指南请参阅 CONTRIBUTING.md

🛠️ 技术栈

需要 JavaScript/FileSystemNode 包?

推荐 NPM 替代方案 📦 Repomix:https://github.com/yamadashy/repomix

🚀 项目成长

星标历史图表