agentleFS
dagarre00dagarre00/claude-code-template/.claude/skills/git-recovery/SKILL.md

git-recovery

Skill1 starsChanged 28 days agoMITView on GitHub

Conductor-only. Emergency and advanced git procedure — undoing commits, recovering lost work (reflog), stash vs checkpoint, cherry-pick, bisect, history rewrites, deleting branches, and resolving merge/rebase/cherry-pick conflicts.

  • Deletes or force-pushes
  • Commits and pushes

4 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 4 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Before any destructive git operation, run git status --porcelain and account for every line (rule 21).

    line 9
  2. Very specific:

    If union-merging docs/wiki/log.md puts entries out of order, sort them oldest-first by ## [YYYY-MM-DD HH:MM] in the merge commit.

    line 29

“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Git Recovery

Before any destructive git operation, run git status --porcelain and account for every line (rule 21).

Rules for the risky operations

  • Destructive = ask first: git reset --hard, git branch -D, git clean, force-push, or any history rewrite requires human-checkpoint approval and a tag first (git tag checkpoint-$(date -u +%Y%m%dT%H%M%SZ)). git reset --soft / git reset of an unpushed commit preserves changes and needs neither.
  • Checkpoint over stash: Pause mid-task with a tagged wip: commit (feature-branching § Mid-task pause). Use stash only for a brief same-session pause (git stash push -u -m "wip: <unique tag>", apply by SHA from git stash list --format='%H %gs', never bare git stash pop).
  • Merge, never rebase, to sync: Rebase + --force-with-lease requires explicit human approval; bare --force or rebasing develop/main is forbidden.
  • Lost commits: Recover from git reflog via git checkout -b recover/<stamp> <sha>.
  • Sensitive data in history: Requires human approval, then git filter-repo --path <file> --invert-paths (never filter-branch).
  • Cherry-pick sparingly (prefer merging related branches).
  • Bisect with git bisect run <test command> and always finish with git bisect reset.
  • Deleting a merged branch: git branch -d <branch> and git push origin --delete <branch> (-D requires approval).

Resolving conflicts

On CONFLICT (content), resolve every hunk on its merits (never take one side wholesale) and complete the operation (git commit or rebase/cherry-pick --continue) only after no conflict markers remain and the full test suite passes.

  • Ambiguous hunk or failing suite after resolution → human-checkpoint.
  • When in doubt with no human available: abort (git merge --abort / rebase --abort / cherry-pick --abort), tag a checkpoint, and run human-checkpoint.

If union-merging docs/wiki/log.md puts entries out of order, sort them oldest-first by ## [YYYY-MM-DD HH:MM] in the merge commit.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.