Communitygithub.com

G1Joshi/Agent-Skills

专业的 Tig 协助工具,涵盖 Git 文本模式界面、交互式暂存、提交图可视化、差异探索和追溯导航。在终端中浏览 Git 提交历史、交互式暂存块、审查文件更改或查看修订时使用。

Agent-Skills 是什么?

该技能为 AI 智能体提供了一套完整的 Tig 使用指南。Tig 是一个基于 ncurses 的 Git 文本模式界面,非常适合在无图形界面的服务器环境中高效浏览 Git 仓库。技能详细介绍了 Tig 的核心用法,包括如何查看提交图、进行交互式暂存(支持 hunk 和行级别暂存)、使用 `tig blame` 追溯代码变更来源,以及通过自定义 `~/.tigrc` 配置文件优化工作流。它支持多种平台,如 Claude Code、Cursor 和 Codex,能够帮助开发者快速导航 Git 历史、审查差异和提交干净代码。该技能还提供了生产环境下的最佳实践(如 2026 年建议)和常见问题排障表,特别适合需要低延迟 Git 审计的企业级 SSH 环境。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/G1Joshi/Agent-Skills/tree/HEAD/skills/tools/tig

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

Tig

Tig 是一个基于 ncurses 的 Git 文本模式界面。它主要用作 Git 仓库浏览器。

何时使用

  • 基于终端的 Git 历史导航:在无图形界面的服务器环境中快速浏览提交图、分支和标签。
  • 交互式暂存与块提交:无需离开终端即可审查差异、暂存块以及撤销未暂存的行。
  • 追溯与注释代码:逐行查看提交作者、时间戳和提交日志(tig blame)。
  • 低开销 Git 审计:通过 SSH 连接审计大型企业 Git 仓库,零图形界面延迟。

快速开始

1. 常用命令

# 打开主分支提交图
tig

# 查看特定文件的历史
tig path/to/file.ts

# 查看未提交更改的差异(状态视图)
tig status

# 交互式追溯视图
tig blame path/to/file.ts

2. 基本导航键

  • m:切换到主(提交图)视图
  • s:切换到状态(暂存)视图
  • d:查看选中提交的差异
  • b:追溯视图
  • u:暂存/取消暂存选中的文件或差异块
  • q:关闭当前视图 / 退出

核心概念

生产环境 Tig 配置(~/.tigrc)

自定义颜色、键绑定和视图布局:

# ~/.tigrc
# 通用设置
set line-graphics = utf-8
set tab-size = 2
set main-view = id date:relative author:email-user commit-title:graph=yes,refs=yes
set diff-view = line-number:yes,interval=5
set status-view = line-number:yes

# 键绑定:Vim 导航
bind generic j move-down
bind generic k move-up
bind generic g move-first-line
bind generic G move-last-line
bind generic <Ctrl-f> page-down
bind generic <Ctrl-b> page-up

# 快速操作
bind main <Enter> view-diff
bind status u stage-update
bind status s stage-update
bind status c !git commit -v

交互式暂存视图与块暂存

导航状态视图以审查和暂存更改:

# 直接在状态模式下打开 Tig
tig status

# 状态视图中的按键:
# - 按 'u' 暂存/取消暂存文件或块
# - 按 'Enter' 打开选中文件的差异视图
# - 按 '1' 暂存单行
# - 按 'c' 打开编辑器并创建提交

使用 tig blame 调查回归

在仓库历史中追溯代码行修改:

# 启动特定文件的交互式追溯查看器
tig blame src/auth/jwt_validator.go

# 追溯视图中的导航:
# - 在任何行上按 'Enter' 查看引入该行的完整提交差异
# - 按 ',' 追溯该更改之前的父提交
# - 按 'q' 返回上一视图

常见模式

#自定义 Tig 键绑定(~/.tigrc) 问题:快速终端暂存、变基和分支切换。
解决方案:在 ~/.tigrc 中定义自定义快捷键。

# ~/.tigrc
# 绑定 'F' 从远程仓库拉取
bind generic F !git fetch origin

# 在状态视图中绑定 'C' 快速提交
bind status C !git commit -v

# 绑定 'P' 推送当前分支
bind generic P !git push origin HEAD

最佳实践(2026)

  • 应当 在 ~/.tigrc 中配置 main-view 的 commit-title:graph=yes,refs=yes 以显示清晰的分支层级。
  • 应当 使用 tig blame 快速发现引入破坏代码行的 PR 或提交。
  • 应当 利用 tig status 审查和暂存单行块(1),以实现精细、整洁的 Git 提交。
  • 应当 在 .tigrc 中将默认导航键重新映射为 j/k(如果您习惯 Vim 键绑定)。
  • 不应 在 Tig 中保留未解决的合并冲突;应使用 Tig 查看冲突状态,然后在编辑器中解决。
  • 不应 在数 GB 大小的仓库上运行完整的全历史 Tig 视图,除非指定了分支或路径限制。
  • 不应 忘记按 q 向上退回到视图层级,而不会终止会话。

故障排除

错误/症状原因解决方案
终端中颜色难以辨认终端主题对比度与默认 Tig 调色板冲突在 ~/.tigrc 中配置自定义颜色(例如 color diff-stat green default)。
Tig 在错误的 Git 仓库根目录下打开当前工作目录在子模块内或仓库外在调用 tig 前检查 git rev-parse --show-toplevel。
追溯视图上出现 cannot open file: ...文件已在工作树中被重命名或删除显式传递提交引用:tig blame HEAD~2 -- path/to/file。

参考

Individual skills in this repo

This repo contains 11 individual skills — each has its own dedicated page.

G1Joshi/Agent-Skills

Expert Dask distributed computing assistance covering Dask DataFrames, Arrays, Futures, and cluster scaling. Use when analyzing datasets too large for pandas on a single machine or multi-node cluster.

G1Joshi/Agent-Skills

Expert dbt (data build tool) assistance covering SQL modeling, Jinja macros, tests, documentation, and semantic layer. Use when building analytics engineering pipelines on BigQuery, Snowflake, or PostgreSQL.

G1Joshi/Agent-Skills

Expert JAX assistance covering Autograd, XLA compilation (`jit`), vectorization (`vmap`), and parallelization (`pmap`). Use when building high-performance numerical computing and cutting-edge deep learning research.

G1Joshi/Agent-Skills

Expert Ray distributed computing assistance covering Ray Core (actors, tasks), Ray Train, Ray Tune, and Ray Serve. Use when scaling Python compute and ML training across multi-node clusters.

G1Joshi/Agent-Skills

Expert Git version control assistance covering branching, interactive rebase, cherry-pick, submodules, worktrees, and conflict resolution. Use when managing source code history and collaboration workflows.

G1Joshi/Agent-Skills

Expert K9s CLI assistance covering terminal Kubernetes cluster navigation, real-time log streaming, port forwarding, and pod debugging. Use when managing and troubleshooting Kubernetes clusters with speed.

G1Joshi/Agent-Skills

Expert SWC assistance covering high-performance Rust-based JavaScript/TypeScript compilation, .swcrc configuration, Jest testing via @swc/jest, and minification. Use when replacing Babel with SWC for faster builds, accelerating test execution, or compiling modern ECMAScript features.

G1Joshi/Agent-Skills

Expert Vim assistance covering modal editing, .vimrc configuration, registers, macros, search/replace, and plugin management via vim-plug. Use when editing text efficiently in terminal environments, writing Vimscript, recording macros, or configuring core Vim settings.

G1Joshi/Agent-Skills

Expert Zed editor assistance covering high-performance Rust-based text editing, multi-buffer editing, language server protocols (LSP), and AI assistant integrations. Use when configuring Zed settings.json, setting up language extensions, collaborating in real-time channels, or optimizing editor startup speed.

G1Joshi/Agent-Skills

Expert Zsh assistance covering shell customization, Oh My Zsh plugins, Zinit plugin manager, prompt engineering (Starship/Powerlevel10k), and shell scripting. Use when configuring .zshrc, writing Zsh automation scripts, optimizing shell startup time, or configuring tab-completion.

G1Joshi/Agent-Skills

Expert [skill-name] assistance covering [feature 1], [feature 2], and [feature 3]. Use when [working with X], [debugging Y], or [implementing Z].

相关技能