gitignore

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Gitignore Management Skill (
ign
)

Gitignore 管理 Skill (
ign
)

ign
(GitHub Gitignore CLI) is a high-performance, explicitly managed, and Agent-friendly
.gitignore
manager built with Rust. Powered by the official github/gitignore repository, it provides modular block-isolated merging, context-aware template detection, smart aliases, fuzzy search, and guaranteed preservation of custom user-defined rules. It operates completely offline by default with zero hidden network requests, synchronizing templates on-demand via explicit commands.

ign
(GitHub Gitignore CLI)是一款高性能、采用显式管理机制且对 Agent 友好的
.gitignore
管理器,使用 Rust 构建。它基于官方 github/gitignore 仓库,提供模块化的块隔离合并、上下文感知模板检测、智能别名、模糊搜索,并保证保留用户定义的自定义规则。默认完全离线运行,不会发起任何隐藏网络请求,仅在显式执行命令时按需同步模板。

1. Prerequisites & Installation

1. 前置条件与安装

Before performing any
.gitignore
operations, the Agent should verify installation and initialization in sequence:
在执行任何
.gitignore
操作前,Agent 应按顺序验证安装和初始化情况:

1.1 Verify and Install the CLI Tool

1.1 验证并安装 CLI 工具

bash
command -v ign >/dev/null 2>&1 || cargo install ign
bash
command -v ign >/dev/null 2>&1 || cargo install ign

1.2 Verify and Initialize the Template Library

1.2 验证并初始化模板库

Check if
~/.config/ign/templates
is initialized. If not ready, clone the official template repository:
bash
ign template status >/dev/null 2>&1 || ign template init

检查
~/.config/ign/templates
是否已初始化。如果尚未就绪,克隆官方模板仓库:
bash
ign template status >/dev/null 2>&1 || ign template init

2. Context-Aware Template Selection

2. 上下文感知的模板选择

When configuring
.gitignore
for a project, the Agent should first inspect the workspace context (project markers, build files, OS, and IDE configuration) to automatically select and combine matching templates:
为项目配置
.gitignore
时,Agent 应首先检查工作区上下文(项目标记、构建文件、操作系统和 IDE 配置),以自动选择并组合匹配的模板:

2.1 Language & Tech Stack Mapping

2.1 语言与技术栈映射

Project Marker / DirectoryRecommended TemplateDescription
Cargo.toml
,
Cargo.lock
Rust
Rust build artifacts (
target/
) and backups
package.json
,
pnpm-lock.yaml
,
yarn.lock
Node
Node.js / Web frontend dependencies and build outputs
pyproject.toml
,
requirements.txt
,
Pipfile
Python
Python virtual environments and
__pycache__/
go.mod
,
go.sum
Go
Go binaries and vendor directories
pom.xml
Java
,
Maven
Java Maven projects
build.gradle
,
build.gradle.kts
,
gradlew
Java
,
Gradle
Gradle / Kotlin / Android projects
composer.json
PHP
PHP Composer dependencies
Gemfile
Ruby
Ruby / Rails dependencies and logs
pubspec.yaml
Dart
,
Flutter
Dart / Flutter cross-platform projects
CMakeLists.txt
,
Makefile
C++
or
C
C / C++ build outputs
deno.json
,
deno.jsonc
Deno
Deno cache and build artifacts
mix.exs
Elixir
Elixir / Phoenix projects
*.sln
,
*.csproj
VisualStudio
.NET / C# solutions
项目标记/目录推荐模板说明
Cargo.toml
、
Cargo.lock
Rust
Rust 构建产物(
target/
)和备份文件
package.json
、
pnpm-lock.yaml
、
yarn.lock
Node
Node.js / Web 前端依赖项和构建输出
pyproject.toml
、
requirements.txt
、
Pipfile
Python
Python 虚拟环境和
__pycache__/
go.mod
、
go.sum
Go
Go 二进制文件和 vendor 目录
pom.xml
Java
、
Maven
Java Maven 项目
build.gradle
、
build.gradle.kts
、
gradlew
Java
、
Gradle
Gradle / Kotlin / Android 项目
composer.json
PHP
PHP Composer 依赖项
Gemfile
Ruby
Ruby / Rails 依赖项和日志
pubspec.yaml
Dart
、
Flutter
Dart / Flutter 跨平台项目
CMakeLists.txt
、
Makefile
C++
或
C
C / C++ 构建输出
deno.json
、
deno.jsonc
Deno
Deno 缓存和构建产物
mix.exs
Elixir
Elixir / Phoenix 项目
*.sln
、
*.csproj
VisualStudio
.NET / C# 解决方案

2.2 Operating System & IDE Templates

2.2 操作系统与 IDE 模板

  • Operating System (add based on current execution environment):
    • Linux:
      Linux
      (maps to
      Global/Linux
      )
    • macOS:
      macOS
      (maps to
      Global/macOS
      )
    • Windows:
      Windows
      (maps to
      Global/Windows
      )
  • Developer Tools / IDE (add based on workspace settings or user preference):
    • VS Code:
      Visual_Studio_Code
      (alias
      vscode
      , maps to
      Global/VisualStudioCode
      )
    • JetBrains (IDEA/CLion/RustRover/PyCharm/GoLand):
      JetBrains
      (alias
      idea
      , maps to
      Global/JetBrains
      )
  • 操作系统(根据当前执行环境添加):
    • Linux:
      Linux
      (映射到
      Global/Linux
      )
    • macOS:
      macOS
      (映射到
      Global/macOS
      )
    • Windows:
      Windows
      (映射到
      Global/Windows
      )
  • 开发工具/IDE(根据工作区设置或用户偏好添加):
    • VS Code:
      Visual_Studio_Code
      (别名
      vscode
      ,映射到
      Global/VisualStudioCode
      )
    • JetBrains(IDEA/CLion/RustRover/PyCharm/GoLand):
      JetBrains
      (别名
      idea
      ,映射到
      Global/JetBrains
      )

2.3 Agent Automated Decision Examples

2.3 Agent 自动化决策示例

bash
undefined
bash
undefined

Example: Rust project detected on Linux with VS Code and JetBrains IDEs

Example: Rust project detected on Linux with VS Code and JetBrains IDEs

ign init Rust macOS Linux JetBrains Visual_Studio_Code
ign init Rust macOS Linux JetBrains Visual_Studio_Code

Example: Frontend Node.js project detected

Example: Frontend Node.js project detected

ign init Node macOS Linux Visual_Studio_Code

---
ign init Node macOS Linux Visual_Studio_Code

---

3. Usage & Commands

3. 用法与命令

3.1 Initialize Project
.gitignore
(
init
)

3.1 初始化项目
.gitignore
(
init
)

  • Initialize with explicitly specified templates:
    bash
    ign init Rust macOS JetBrains Visual_Studio_Code
  • Interactive multi-select selection:
    bash
    ign init -i
  • Re-initialize existing file while preserving manual custom rules:
    bash
    ign init Rust macOS
  • 使用显式指定的模板进行初始化:
    bash
    ign init Rust macOS JetBrains Visual_Studio_Code
  • 交互式多选:
    bash
    ign init -i
  • 重新初始化现有文件,同时保留手动添加的自定义规则:
    bash
    ign init Rust macOS

3.2 Append & Update Templates (
add
)

3.2 追加与更新模板(
add
)

Safely append new language or tool templates into an existing
.gitignore
(auto-deduplicated, preserving custom rules):
bash
ign add Linux Python
将新的语言或工具模板安全地追加到现有
.gitignore
中(自动去重并保留自定义规则):
bash
ign add Linux Python

3.3 Inspect & Audit Applied Templates (
status
)

3.3 检查与审计已应用的模板(
status
)

Inspect metadata of the current repository's
.gitignore
(applied templates, timestamps, custom rules):
bash
undefined
检查当前仓库
.gitignore
的元数据(已应用的模板、时间戳、自定义规则):
bash
undefined

Human-readable terminal output

Human-readable terminal output

ign status
ign status

Structured JSON output for Agent/CI consumption

Structured JSON output for Agent/CI consumption

ign status --json

**JSON Output Schema**:
```json
{
  "file_exists": true,
  "path": ".gitignore",
  "managed_by_ign": true,
  "templates_count": 4,
  "templates": [
    "Rust",
    "Global/macOS",
    "Global/JetBrains",
    "Global/VisualStudioCode"
  ],
  "created_at": "2026-08-29T04:33:10Z",
  "updated_at": "2026-08-29T04:33:21Z",
  "has_custom_rules": true,
  "custom_rules_lines": 2,
  "custom_rules": "# Custom user rule\nscratch/",
  "total_lines": 220
}
ign status --json

**JSON 输出结构**:
```json
{
  "file_exists": true,
  "path": ".gitignore",
  "managed_by_ign": true,
  "templates_count": 4,
  "templates": [
    "Rust",
    "Global/macOS",
    "Global/JetBrains",
    "Global/VisualStudioCode"
  ],
  "created_at": "2026-08-29T04:33:10Z",
  "updated_at": "2026-08-29T04:33:21Z",
  "has_custom_rules": true,
  "custom_rules_lines": 2,
  "custom_rules": "# Custom user rule\nscratch/",
  "total_lines": 220
}

3.4 Remove Specified Templates (
remove
)

3.4 移除指定模板(
remove
)

Remove templates from
.gitignore
while keeping remaining templates and custom rules intact:
bash
ign remove Global/macOS
从
.gitignore
中移除指定模板,同时保持其余模板和自定义规则完好:
bash
ign remove Global/macOS

Or using smart alias:

Or using smart alias:

ign remove macos
undefined
ign remove macos
undefined

3.5 Search & Explore Templates (
search
/
list
/
show
)

3.5 搜索与浏览模板(
search
/
list
/
show
)

bash
undefined
bash
undefined

Fuzzy search templates

Fuzzy search templates

ign search elixir ign search jetbrains --json
ign search elixir ign search jetbrains --json

View raw template contents

View raw template contents

ign show Rust
ign show Rust

List all templates in a category

List all templates in a category

ign list -c global
undefined
ign list -c global
undefined

3.6 Local Template Repository Maintenance (
template
)

3.6 本地模板仓库维护(
template
)

bash
undefined
bash
undefined

Inspect local template library status and directory path

Inspect local template library status and directory path

ign template status ign template path
ign template status ign template path

Manually pull latest templates from GitHub

Manually pull latest templates from GitHub

ign template update
ign template update

(Top-level shorthand: ign update)

(Top-level shorthand: ign update)


---

---

4. Environment Variables

4. 环境变量

  • Default template storage path:
    ~/.config/ign/templates
  • Custom storage path override:
    export IGN_TEMPLATES_DIR="/path/to/custom/gitignore-repo"
  • 默认模板存储路径:
    ~/.config/ign/templates
  • 自定义存储路径覆盖:
    export IGN_TEMPLATES_DIR="/path/to/custom/gitignore-repo"