CLI 目录 横向对比 FCRS-1.0 标准 /llms.txt
← 返回 CLI 目录

Git

$ git 基金会 中风险
Git Project · 代码托管与研发协同 · GPL-2.0 · macos / linux / windows

现代软件仓库标准的分布式版本控制系统。提供可脚本化的 --porcelain 状态格式、--no-pager 输出以及部分写操作的 --dry-run,但破坏性历史命令仍需严格护栏约束。

FCRS-1.0 综合评分
88 /100
良好 (Good)
高置信度 (实测)
零摩擦安装命令
brew install git
CLI vs MCP 选型建议 仅 CLI 可用

将 git 保留为直接 Shell CLI:本地工作区检查、暂存与 diff 需要亚毫秒级文件系统访问,MCP 封装只会引入额外延迟。

Agent 友好度体检单

本地探针实测证据
— 原生 JSON 输出
— 字段裁剪
✓ 无头非交互
✓ 支持 Dry-Run
— 只读模式开关
✓ 支持 NO_COLOR
✓ 自省/Schema 发现
— 官方 SKILL.md
实测版本
git version 2.54.0 (Apple Git-157)
冷启动耗时
8 ms
退出码 (help / 非法参数)
0 / 129
NO_COLOR 无色码污染 / 无 TTY 不挂起
Yes / Safe
抓取的 --help 摘要
usage: git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--no-lazy-fetch]
           [--no-optional-locks] [--no-advice] [--bare] [--git-dir=<path>]
           [--work-tree=<path>] [--namespace=<name>] [--config-env=<name>=<envvar>]
           <command> [<args>]

These are common Git commands used in various situations:

start a working area (see also: git help tutorial)
   clone      Clone a repository into a new directory
   init       Create an empty Git repository or reinitialize an existing one

work on the current change (see also: git help everyday)
   add        Add file contents to the index
   mv         Move or rename a file, a directory, or a symlink
   restore    Restore working tree files
   rm         Remove files from the working tree and from the index

examine the history and state (see also: git help revisions)
   bisect     Use binary search to find the commit that introduced a bug
   diff       Show changes between commits, commit and working tree, etc
   grep       Print lines matching a pattern
   log        Show commit logs
   show       Show various types of objects
   status     Show the working tree status

grow, mark and tweak your common history
   backfill   Download missing objects in a partial clone
   branch     List, create, or delete branches
   commit     Record changes to the repository
   history    EXPERIMENTAL: Rewrite history
   merge      Join two or more development histories together
   rebase     Reapply commits on top of another base tip
   reset      Set `HEAD` or the index to a known state
   switch     Switch branches
   tag        Create, list, delete or verify tags

collaborate (see also: git help workflows)
   fetch      Download objects and refs from another repository
   pull       Fetch from and integrate with another repository or a local branch
   push       Update remote refs along with associated objects

'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.
See 'git help git' for an overview of the system.

FCRS-1.0 六维评分拆解

Agent 友好度 19 / 25

提供 --porcelain=v2、--no-pager 与 GIT_TERMINAL_PROMPT=0 用于无头脚本,但各子命令缺少统一的 --json 输出。

  • Supports git status --porcelain=v2 and git --no-pager
  • Supports GIT_TERMINAL_PROMPT=0 to prevent credential prompt hangs
安全与权限边界 20 / 25

git clean 与 git push 等支持 --dry-run(-n),但 git reset --hard 等命令可能不可逆地丢弃未提交修改。

  • git clean -n and git push --dry-run preview side effects
  • Destructive commands (reset --hard, push --force) require policy guardrails
安装与运行摩擦 15 / 15

预装或极易安装于 macOS、Linux 和 Windows,体积小巧。

  • Native packages on all major OSes and CI runners
能力覆盖与边际价值 15 / 15

不可或缺的源码管理底座,plumbing 与 porcelain 命令完整覆盖所有仓库工作流。

  • Full local and remote repository lifecycle coverage
维护与来源背书 10 / 10

由 Software Freedom Conservancy 支持的成熟基础项目,持续稳定维护与更新。

  • Maintained by the Git Project under GPL-2.0
文档与可验证性 9 / 10

内置完善的联机手册(git help <cmd>)与官方参考文档。

  • Complete command reference at git-scm.com/docs

安全边界、鉴权与放权指南

鉴权方式
无需鉴权 系统钥匙串 本地配置文件 环境变量密钥
凭证存储位置

将远程认证委托给 git-credential 助手(macOS 钥匙串、libsecret、Windows 凭证管理器)、SSH 密钥或 ~/.git-credentials。

潜在副作用
只读查询 本地写入 远端写入 破坏性删除
费用与配额提示

基于 GPL-2.0 协议免费开源,无额外运行服务费用。

可复制到 CLAUDE.md / AGENTS.md 的安全护栏
# Git (git) Agent Rules
- Always pass `--no-pager` (or set `GIT_PAGER=cat`) and `GIT_TERMINAL_PROMPT=0` in automation.
- Never run `git reset --hard`, `git clean -fd`, or `git push --force` without explicit user approval.
- Inspect changes with `git status --porcelain=v2` and `git diff` before staging or committing.

Agent 高频安全命令配方

只读查询(安全推荐)

获取机读格式仓库状态
git --no-pager status --porcelain=v2 --branch

输出稳定的可解析状态与分支跟踪信息,且不启动交互式分页器。

紧凑查看近期提交历史
git --no-pager log -n 15 --oneline --no-decorate

返回精简的提交哈希与标题,便于快速收集上下文。

受控写入与预演

安全预演未跟踪文件清理
git clean -nd

使用 -n(--dry-run)在实际删除前列出将被清理的未跟踪文件与目录。

核心优势

  • + 可脚本化的 --porcelain=v2 状态与 -z 空字符分隔输出能安全处理任意文件名。
  • + GIT_TERMINAL_PROMPT=0 与 --no-pager 可有效防止交互式 TTY 阻塞。
  • + 全平台随处可用,无需额外运行时配置。

注意事项与踩坑点

  • ! log、diff、branch 等命令缺少统一的 --json 输出参数。
  • ! git reset --hard、git clean -fd 等工作区破坏性命令可能清空未提交的修改。

已验证兼容的 Agent 宿主

Claude Code Codex CLI Gemini CLI