git-safety-net

Audits, preserves, recovers, and safely retires local Git work across checkouts, stashes, and dangling commits.

1.4k|216|Updated Oct 22, 2025
One-click install
npx skills add https://github.com/daymade/claude-code-skills --skill git-safety-net
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-safety-net
Source: https://github.com/daymade/claude-code-skills/tree/main/git-safety-net
Command: npx skills add https://github.com/daymade/claude-code-skills --skill git-safety-net

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

Local Git work gets lost in ways standard commands cannot see: unpushed commits on forgotten branches, untracked files no bundle can back up, orphaned stashes, dangling commits eligible for garbage collection, and independent clones of the same repository that git worktree list is structurally blind to. This Skill audits every hiding place, preserves at-risk work before any destructive action, and recovers commits that appear lost.

Core Features & Use Cases

  • Loss recovery: Uses git reflog first, then targeted routes for dropped stashes, detached-HEAD work, and true orphans found via git fsck, always recovering onto a new branch rather than resetting live work.
  • Machine-wide audit: Discovers every checkout of a repository including independent clones, then reports local-only commits, dirty worktrees, stashes, and dangling commits with clear exit codes.
  • Content-based merge verification: Uses a trial three-way merge (git merge-tree) instead of commit counts, so squash-merged branches correctly read as merged.
  • Safe retirement: Exports stashes, branches, and full ref bundles with verification before any branch deletion, worktree removal, or clone cleanup.
  • Use Case: Before deleting an old feature branch that shows "173 commits ahead of main", run the merge verification to confirm the content actually landed, then export a verified bundle before deleting.

Quick Start

Ask the assistant to audit this repository for any work that would be lost if I cleaned up my branches, worktrees, and stashes right now.

Frequently Asked Questions about git-safety-net

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I recover a lost Git commit or deleted branch?

Start with `git reflog --date=iso`, which records every HEAD position for about 90 days and contains most lost commits. Confirm the commit with `git show <sha>`, then recover it onto a new branch with `git switch -c rescue/<name> <sha>` rather than resetting live work.

How do I check if a branch is fully merged before deleting it?

Verify by content, not commit count, because squash merges make merged branches show many phantom unmerged commits. The git_verify_branch_merged.sh script runs a trial three-way merge with `git merge-tree` and reports MERGED only when the merge changes nothing.

Why does git worktree list not show all my clones?

`git worktree list` only sees linked worktrees created with `git worktree add`; an independent `git clone` has its own complete .git directory and no back-reference. The git_find_all_checkouts.sh script scans the filesystem and matches clones by normalized remote URL or shared commit history.

Can git bundle or format-patch back up untracked files?

No. Bundle, archive, and format-patch only reach objects Git already knows about, so a file never added or stashed exists only on disk. Preserve untracked work by copying the files directly to a backup directory outside the repository.

Is it safe to run these audit scripts on a dirty working tree?

Yes. The audit and discovery scripts are non-destructive: they run read-only Git queries, disable fsmonitor, and never fetch, write refs, or touch files. Only explicitly labeled steps like branch deletion or worktree removal are destructive, and each requires prior preservation.

What are the limitations of stash-based backups before cleanup?

Stashes are local-only by nature and lost with the disk, and `git stash show -p` omits the untracked third parent created by `stash -u`. The export script writes both a full patch and a separate tar of untracked files so nothing is silently dropped.