← 返回 CLI 目录 抓取的
Git LFS
$ git-lfs 基金会 低风险 Git LFS Contributors · 代码托管与研发协同 · MIT · macos / linux / windows
将 Git 仓库中的大型二进制文件替换为轻量级文本指针,并将实际内容存储在远程 LFS 服务器。Agent 可通过 git lfs ls-files、git lfs status 与 git lfs prune --dry-run 安全检查和管理大文件存储。
FCRS-1.0 综合评分
83 /100
良好 (Good)
高置信度 (实测)
零摩擦安装命令
brew install git-lfs CLI vs MCP 选型建议 仅 CLI 可用
二进制指针解析与本地 .git/lfs 缓存清理均属于纯本地 Git 操作,没有 MCP 替代必要性。
Agent 友好度体检单
本地探针实测证据 — 原生 JSON 输出
— 字段裁剪
✓ 无头非交互
✓ 支持 Dry-Run
— 只读模式开关
— 支持 NO_COLOR
✓ 自省/Schema 发现
— 官方 SKILL.md
实测版本
git-lfs/3.7.0 (GitHub; darwin arm64; go 1.24.4)
冷启动耗时
155 ms
退出码 (help / 非法参数)
0 / 127
NO_COLOR 无色码污染 / 无 TTY 不挂起
Yes / Safe
抓取的 --help 摘要
git lfs <command> [<args>]
Git LFS is a system for managing and versioning large files in
association with a Git repository. Instead of storing the large files
within the Git repository as blobs, Git LFS stores special "pointer
files" in the repository, while storing the actual file contents on a
Git LFS server. The contents of the large file are downloaded
automatically when needed, for example when a Git branch containing the
large file is checked out.
Git LFS works by using a "smudge" filter to look up the large file
contents based on the pointer file, and a "clean" filter to create a new
version of the pointer file when the large file's contents change. It
also uses a pre-push hook to upload the large file contents to the Git
LFS server whenever a commit containing a new large file version is
about to be pushed to the corresponding Git server.
Commands
--------
Like Git, Git LFS commands are separated into high level ("porcelain")
commands and low level ("plumbing") commands.
High level porcelain commands
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
git lfs checkout:
Populate working copy with real content from Git LFS files.
git lfs completion:
Generate shell scripts for command-line tab-completion of Git LFS commands.
git lfs dedup:
De-duplicate Git LFS files.
git lfs env:
Display the Git LFS environment.
git lfs ext:
Display Git LFS extension details.
git lfs fetch:
Download Git LFS files from a remote.
git lfs fsck:
Check Git LFS files for consistency.
git lfs install:
Install Git LFS configuration.
git lfs lock:
Set a file as "locked" on the Git LFS server.
git lfs locks:
List currently "locked" files from the Git LFS server.
git lfs logs:
Show errors from the Git LFS command.
git lfs ls-files:
Show information about Git LFS files in the index
and working tree.
git lfs migrate:
Migrate history to or from Git LFS
git lfs prune:
Delete old Git LFS files from local storage
git lfs pull:
Fetch Git LFS changes from the remote & checkout any required working tree
files.
git lfs push:
Push queued large files to the Git LFS endpoint.
git lfs status:
Show the status of Git LFS files in the working
tree.
git lfs track:
View or add Git LFS paths to Git attributes.
git lfs uninstall:
Uninstall Git LFS by removing hooks and smudge/clean filter configuration.
git lfs unlock:
Remove "locked" setting for a file on the Git LFS server.
git lfs untrack:
Remove Git LFS paths from Git Attributes.
git lfs update:
Update Git hook FCRS-1.0 六维评分拆解
Agent 友好度 18 / 25
命令无交互且确定性强(如 ls-files、status --porcelain、locks --json),但多数子命令仅输出纯文本而非 JSON。
git lfs ls-files --longandgit lfs status --porcelainprovide clean output- Lacks universal
--jsonacross most commands
安全与权限边界 21 / 25
指针模型安全,prune 与 migrate 支持 --dry-run,且继承 Git 凭证隔离。
git lfs prune --dry-runandgit lfs migrate infoprevent blind mutations
安装与运行摩擦 14 / 15
静态 Go 单二进制,可通过 Homebrew 与官方安装包在 macOS、Linux 和 Windows 上运行。
- Cross-platform binary installed via
brew install git-lfs
能力覆盖与边际价值 13 / 15
通过透明的 Git filter 钩子干净解决仓库大文件膨胀问题。
- Handles pointer hydration and upload transparently on
gitcommands
维护与来源背书 9 / 10
由 GitHub 发起并由社区长期维护的成熟 MIT 项目。
- Active
git-lfs/git-lfsrepository under MIT license
文档与可验证性 8 / 10
具备完善的联机手册页与子命令 --help 文档。
- Complete command manpages in
git-lfs/docs
安全边界、鉴权与放权指南
鉴权方式
无需鉴权 系统钥匙串 本地配置文件
凭证存储位置
继承宿主仓库的 Git 凭证助手与 SSH 认证;服务器覆盖配置位于 .lfsconfig。
潜在副作用
只读查询 本地写入 远端写入
费用与配额提示
MIT 开源免费 CLI;远程 LFS 存储与流量配额取决于所用的 Git 托管平台。
可复制到 CLAUDE.md / AGENTS.md 的安全护栏
# Git LFS (git-lfs) Agent Rules - Run `git lfs track` before committing large binaries so files are not stored directly in Git history. - Always preview cache cleanup with `git lfs prune --dry-run` before running `git lfs prune`.
Agent 高频安全命令配方
只读查询(安全推荐)
列出受追踪的 LFS 文件与 OID
git lfs ls-files --long
在不修改仓库的前提下列出 LFS 路径及完整 SHA-256 对象 ID。
查看 LFS 追踪规则
git lfs track
打印当前 .gitattributes 中配置的 LFS 追踪模式。
受控写入与预演
预演本地 LFS 缓存清理
git lfs prune --dry-run
报告可清理的旧本地 LFS 对象,但不执行实际删除。
核心优势
- +
git lfs prune --dry-run与git lfs migrate info允许 Agent 安全评估影响。 - + 单 Go 二进制可直接作为
git lfs子命令集成。 - + 直接复用标准 Git 认证,无需额外配置 Token。
注意事项与踩坑点
- ! 仅
git lfs locks --json等少数命令支持 JSON,多数命令输出纯文本。 - ! 在全新容器中若忘记执行
git lfs install,检出时文件会保留为未还原的指针文本。
已验证兼容的 Agent 宿主
Claude Code Codex CLI Gemini CLI