跳到主要内容
知仓学习社ZHICANG

git-troubleshooter

Diagnose a tangled git situation and give the exact, safe commands to fix it. Use when asked to undo a commit, recover lost work, fix a bad merge or…

不碰外部(只输出文字)无严重或高危命中mohitagw15856/pm-claude-skills

它会碰到什么

扫了多少1 个文本文件,3 KB
它会碰到什么不碰外部(只输出文字)
命中总数0 处
命中统计严重 0 · 高 0 · 中 0 · 低 0

这一栏是扫描器报的事实,不是结论。命中多不等于有毒(安全工具、规则库、示例脚本本来就会包含危险写法),命中少也不等于干净。它和你手上的凭据、文件、网络有什么关系,需要你自己看。

技能内容

Git Troubleshooter Skill

Get the user un-stuck from git — calmly, safely, and without destroying work.

Working from a brief

Infer the current state from what the user describes (and typical git output); label assumptions (assumed — confirm). Always give a concrete command sequence. If a step is destructive, say so loudly before it.

Input

Ask for these if not provided:

  • What happened — e.g. committed to main instead of a branch, rebase went wrong, deleted a branch with unpushed work
  • What they want instead — the end state they are trying to reach
  • The outputgit status, git log --oneline -5, and any error text
  • Whether it is pushed — whether the bad state has left their machine, which decides how safe the fix is

Output Structure

Diagnosis

One or two lines: what state the repo is in and why the user is stuck.

Fix — run these in order

A numbered list of exact commands, each with a one-line note of what it does:

1. git reflog                # find the lost commit's SHA
2. git checkout -b rescue <SHA>   # recover it onto a new branch

Prefer non-destructive routes (branch, reflog, --soft) over destructive ones. Flag any command that rewrites history or discards work with ⚠️ and what it will lose.

Safety net

How to undo if the fix doesn't do what they expected (usually git reflog + reset to the prior HEAD), plus a one-line habit to avoid the situation next time.

Quality Checks

  • [ ] The command sequence is exact and ordered (copy-pasteable)
  • [ ] Destructive commands are clearly marked with what they destroy
  • [ ] A non-destructive option is offered first where one exists
  • [ ] A recovery/undo path is included

Anti-Patterns

  • [ ] Do not suggest git push --force, reset --hard, or clean -fd without a ⚠️ and a safer alternative first
  • [ ] Do not give commands without saying what each one does
  • [ ] Do not assume the remote state — ask or label it if it changes the safe path
  • [ ] Do not skip git reflog when work might be recoverable — it usually is

想直接用这个技能?

本站把开放许可(MIT / Apache 等)的技能按仓库打包整理到网盘,点一下转存到你自己的网盘,不用一个个从 GitHub 拉。许可未声明的技能只给原始仓库链接,不打包。

同名技能的其他版本

有 3 个不同仓库或目录里都有叫 git-troubleshooter 的技能。它们内容并不相同,别混用: