gitfile 是一个高效的 Git 仓库分析工具,专为解析 Git 仓库的 .git 目录设计,可统计所有历史出现过的文件路径、定位特定 OID 对应的 Git 对象,并展示 Git 各类对象(Commit/Tree/Blob/Tag)的数量和大小统计信息。
- 🚀 多线程处理:自动适配 CPU 核心数(也可手动指定),大幅提升扫描效率
- 📝 文件路径统计:输出 Git 仓库中所有历史出现过的唯一文件路径
- 🔍 OID 定位:根据指定 OID 查找对应的 Git 对象,输出其位置及父级对象信息
- 📊 对象统计:展示 Commit/Tree/Blob/Tag 等 Git 对象的数量和大小统计
- 🔄 递归扫描:可配置递归深度,批量扫描指定目录下的所有 Git 仓库
cargo install gitfiledocker 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 |
查看帮助信息 | - |
# 本地安装版
gitfile /path/to/your/repo/.git
# Docker 版(需挂载主机目录到容器)
docker run --rm -v /host/path/to/repo:/repo 007gzs/gitfile /repo/.git# 本地安装版
gitfile -d 3 /path/to/root/directory
# Docker 版
docker run --rm -v /host/path/to/root:/root 007gzs/gitfile -d 3 /root# 本地安装版
gitfile -f 1a2b3c4d5e6f7890abcdef1234567890abcdef12 /path/to/repo/.git
# Docker 版
docker run --rm -v /host/path/to/repo:/repo 007gzs/gitfile -f 1a2b3c4d5e6f7890abcdef1234567890abcdef12 /repo/.git# 本地安装版
gitfile -s /path/to/repo/.git
# Docker 版
docker run --rm -v /host/path/to/repo:/repo 007gzs/gitfile -s /repo/.git# 本地安装版
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