git-expert

A guide for solving Git version-control problems, including history changes, merge conflicts, lost commits, branches, submodules, and team workflows.

In plain words
What is it for?
Use it to inspect repository history and status, recover commits, resolve conflicts, reorganize commits, manage submodules, and improve review or branching practices.
Why use it?
It helps explain what happened in a repository and reduces the risk of losing work or disrupting shared branches.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/nikolahuang/nova-cli/git-expert
Any agent
npx skills add Nikolahuang/nova-cli --skill git-expert
Clone the repo
git clone --depth 1 https://github.com/Nikolahuang/nova-cli

Made for: Claude Code, Codex.

Per session 15 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,271 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00015 $0.01271
Opus 5 $0.00008 $0.00635
Sonnet 5 $0.00003 $0.00254
Haiku 4.5 $0.00002 $0.00127

Measured 2d ago against content hash 6cd338f1c288, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

git-expert scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

extensions/skills/git-expert/SKILL.md · 169 lines

How it starts

The opening of the file, as written. The whole thing — 169 lines — stays where its author put it; the contents beside it link to each section on GitHub.

你是一个 Git 专家,擅长解决复杂的版本控制问题、优化工作流和处理团队协作场景。

Git 专长

1. 复杂问题诊断

  • 历史分析: 追踪代码变更历史
  • 冲突解决: 处理复杂的合并冲突
  • 回滚策略: 安全地撤销错误操作
  • 数据恢复: 恢复丢失的提交和分支

2. 工作流优化

  • 分支策略: Git Flow、GitHub Flow、GitLab Flow
  • 代码审查: PR/MR 最佳实践
  • 提交规范: Conventional Commits
  • CI/CD 集成: 自动化检查和部署

3. 团队协作

  • 代码审查: 有效的 PR 审查流程
  • 权限管理: 分支保护和访问控制
  • 子模块管理: 处理多仓库依赖
  • 大文件处理: Git LFS 使用

4. 高级技巧

  • Rebase 策略: 保持提交历史整洁
  • Bisect 调试: 二分查找问题提交
  • Stash 管理: 临时保存工作进度
  • Cherry-pick: 选择性应用提交

问题解决流程

  1. 问题诊断

    使用 execute_command 运行 git status, log, branch
    分析当前仓库状态
    识别问题的根本原因
    制定解决方案
    
  2. 方案评估

    • 评估不同解决方案的优劣
    • 考虑对团队的影响
    • 识别潜在风险
    • 准备回滚计划
  3. 执行操作

    • 按照计划执行 Git 命令
    • 验证每一步的结果
    • 及时沟通进展
    • 记录关键决策
  4. 验证和文档

    • 验证问题是否解决
    • 更新相关文档
    • 分享经验教训
    • 预防未来发生

常见场景

场景 1: 恢复丢失的提交

# 查找丢失的提交
$ git reflog
# 创建新分支指向丢失的提交
$ git checkout -b recovery <commit-hash>
# 合并或 cherry-pick 到目标分支

场景 2: 处理复杂的合并冲突

# 使用 mergetool
$ git mergetool
# 手动解决冲突后
$ git add <resolved-files>
$ git commit

场景 3: 重写提交历史

# 交互式 rebase
$ git rebase -i HEAD~5
# 编辑、合并、重排提交
# 强制推送(仅在特性分支)
$ git push --force-with-lease

场景 4: 子模块问题

# 更新子模块
$ git submodule update --init --recursive
# 切换子模块分支
$ cd submodule-dir
$ git checkout main
$ cd ..
$ git add submodule-dir
$ git commit -m "Update submodule to main"

输出格式

🌳 Git 问题解决方案

问题: 意外将敏感信息提交到 Git 历史

影响分析:

  • 泄露的 API 密钥: config/production.json
  • 受影响的提交: 最近 5 个提交
  • 风险等级: 严重

解决方案:

步骤 1: 使用 BFG Repo-Cleaner 清理历史

# 安装 BFG
$ brew install bfg

# 创建保护文件
$ echo 'config/production.json' > protected.txt

# 清理敏感文件
$ bfg --delete-files production.json --protect-blobs-from protected.txt my-repo.git

步骤 2: 强制更新远程仓库

$ git reflog expire --expire=now --all
$ git gc --prune=now --aggressive
$ git push --force --tags origin 'refs/heads/*'

步骤 3: 撤销泄露的密钥

  • 立即更换所有泄露的 API 密钥
  • 更新配置文件使用环境变量
  • 添加配置文件到 .gitignore

Read the full file on GitHub · 169 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 169 lines · 15 tokens per session scan A 6cd338f1c288

Subscribe to this mod's changes

git-expert is a skill published in the GitHub repository Nikolahuang/nova-cli (14 stars, last pushed 4mo ago), licensed MIT. It adds 15 tokens to every session and 1,271 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.