Files
opencode/command/git-add.md

2.3 KiB

description
description
Stage changes with automatic filtering of sensitive files

Intelligently stage changes while automatically filtering security-sensitive files.

Please perform the following:

  1. Detect all unstaged changes:

    • Modified files (M)
    • Deleted files (D)
    • Untracked files (??) - 重要:第一次就显示并提供选项
  2. Filter sensitive files - Automatically exclude:

    • .env* - Environment files
    • *.key, *.pem, *.p8 - Private keys
    • .aws/*, .gcloud/*, .ssh/* - Cloud/SSH credentials
    • credentials.json, secrets.json - Credential files
    • node_modules/, vendor/, .venv/ - Dependencies
    • dist/, build/, .next/ - Build artifacts
    • .DS_Store, Thumbs.db - System files
  3. Categorize files:

    • 已跟踪的修改/删除 (tracked modified/deleted)
    • 未跟踪的安全文件 (untracked safe files)
    • 敏感文件 (sensitive files - filtered)
  4. Display preview in Chinese:

=== 将要暂存的文件 (N) ===
M  [tracked modified files]
D  [tracked deleted files]

=== 未跟踪的文件 (N) ===
?? [untracked safe files]

=== 敏感文件已过滤 (N) ===
⚠ [sensitive files with reasons]

=== 操作选项 ===
- 输入 "y" 或 "yes" 暂存已修改/已删除的文件(不包括未跟踪文件)
- 输入 "all" 或 "u" 暂存所有安全文件(包括未跟踪文件)✓ 推荐
- 输入 "force" 强制暂存所有文件(包括敏感文件)⚠️ 谨慎使用
- 输入 "no" 或 "cancel" 取消操作
- 输入文件路径 暂存特定文件
  1. Wait for user confirmation

  2. Execute staging based on user choice:

    • y/yes: Stage tracked modified/deleted only
    • all/u: Stage all safe files (including untracked)
    • force: Show warning, require "confirm" input, then stage everything
    • no/cancel: Abort
    • File path: Stage specific file(s)
  3. Display result in Chinese:

✓ 暂存成功

已暂存 N 个文件:
  [列出已暂存的文件]

敏感文件已过滤并排除,保护了你的凭证信息。

下一步:
- 运行 /git-commit 生成提交信息并提交
- 运行 /git-status 查看暂存区状态

重要:第一次运行就显示所有选项,包括未跟踪文件的处理方式,不需要用户多次运行命令。