# gitfile **Repository Path**: 007gzs/gitfile ## Basic Information - **Project Name**: gitfile - **Description**: 高效的 Git 分析工具 - **Primary Language**: Rust - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2026-04-22 - **Last Updated**: 2026-04-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # gitfile gitfile 是一个高效的 Git 仓库分析工具,专为解析 Git 仓库的 `.git` 目录设计,可统计所有历史出现过的文件路径、定位特定 OID 对应的 Git 对象,并展示 Git 各类对象(Commit/Tree/Blob/Tag)的数量和大小统计信息。 ## 功能特性 - 🚀 多线程处理:自动适配 CPU 核心数(也可手动指定),大幅提升扫描效率 - 📝 文件路径统计:输出 Git 仓库中所有历史出现过的唯一文件路径 - 🔍 OID 定位:根据指定 OID 查找对应的 Git 对象,输出其位置及父级对象信息 - 📊 对象统计:展示 Commit/Tree/Blob/Tag 等 Git 对象的数量和大小统计 - 🔄 递归扫描:可配置递归深度,批量扫描指定目录下的所有 Git 仓库 ## 安装方式 ### 方式 1:通过 Cargo 安装(需 Rust 环境) ```bash cargo install gitfile ``` ### 方式 2:通过 Docker 安装 ```bash docker pull 007gzs/gitfile ``` ## 使用说明 ### 命令行参数 | 参数 | 说明 | 默认值 | | ------------------ | ------------------------------------------------------------ | ------ | | `root_path` (必填) | 扫描的根目录(支持传入多个目录) | - | | `-d/--max-depth` | 最大递归深度(0 表示不递归,仅扫描指定目录) | 0 | | `-s/--show-object` | 开启「显示所有 Git 对象」模式(输出每个对象的 OID、类型、大小) | false | | `-f/--find-oid` | 根据指定 OID 查找对应的 Git 对象,输出其位置和父级对象信息 | 空 | | `-t/--thread-num` | 线程数(0 表示自动使用 CPU 核心数,最大值 255) | 0 | | `--version` | 查看版本信息 | - | | `--help` | 查看帮助信息 | - | ### 使用示例 #### 1. 基本扫描(输出指定.git 仓库的所有唯一文件路径) ```bash # 本地安装版 gitfile /path/to/your/repo/.git # Docker 版(需挂载主机目录到容器) docker run --rm -v /host/path/to/repo:/repo 007gzs/gitfile /repo/.git ``` #### 2. 递归扫描(深度为 3,扫描指定目录下所有.git 仓库) ```bash # 本地安装版 gitfile -d 3 /path/to/root/directory # Docker 版 docker run --rm -v /host/path/to/root:/root 007gzs/gitfile -d 3 /root ``` #### 3. 查找指定 OID 的 Git 对象 ```bash # 本地安装版 gitfile -f 1a2b3c4d5e6f7890abcdef1234567890abcdef12 /path/to/repo/.git # Docker 版 docker run --rm -v /host/path/to/repo:/repo 007gzs/gitfile -f 1a2b3c4d5e6f7890abcdef1234567890abcdef12 /repo/.git ``` #### 4. 显示所有 Git 对象信息(OID、类型、大小) ```bash # 本地安装版 gitfile -s /path/to/repo/.git # Docker 版 docker run --rm -v /host/path/to/repo:/repo 007gzs/gitfile -s /repo/.git ``` #### 5. 指定线程数扫描(8 线程) ```bash # 本地安装版 gitfile -t 8 /path/to/repo/.git # Docker 版 docker run --rm -v /host/path/to/repo:/repo 007gzs/gitfile -t 8 /repo/.git ``` ## 许可证 本项目基于 **MIT** 或 **Apache-2.0** 双许可证开源,详见项目根目录的 LICENSE 文件。 ## 仓库地址 - GitHub: https://github.com/007gzs/gitfile - crates.io: https://crates.io/crates/gitfile - Docker Hub: https://hub.docker.com/r/007gzs/gitfile