[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6QJ06VKATRG1SGTM7W9K5ZX":3,"skill-same:01M6QJ06VKATRG1SGTM7W9K5ZX":70},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":38,"linkOnly":39,"markdownContent":40,"markdownBody":41,"frontMatter":42,"refName":50,"commitSha":51,"skillDirectory":52,"forksCount":13,"repositoryHtmlUrl":53,"repositoryHomepageUrl":6,"ownerHtmlUrl":54,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":55,"install":56,"resources":69},"01M6QJ06VKATRG1SGTM7W9K5ZX","git-history-rewrite",null,"Master git history manipulation: when modifying history is safe, git reset\u002Frebase alternatives, and maintaining history integrity. Use when user mentions git history, rewriting commits, git reset, amending commits, or when they want to clean up commit history. Triggers especially when user says \"clean up history\", \"rewrite git history\", \"git reset\", \"amend commit\", or \"squash commits\".","ImaginerLabs\u002Fskill-manager","ImaginerLabs","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F214277308?v=4","01M6QGGDPNF15RMMT1RCFDH9FN","01M6QGGDTH5BY64DQ123NR8M33",0,"MIT","https:\u002F\u002Fgithub.com\u002FImaginerLabs\u002Fskill-manager\u002Fblob\u002Fmain\u002Fskills\u002Fcoding\u002Fgit-history-rewrite\u002FSKILL.md",[],[18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37],"git history rewrite","git","rewrite","history","use","alternatives","reset","triggers","squash commits","clean","master","up","safe","coding","squash","rebase","amend","commits","integrity","commit","2026-11-10 10:12:30",false,"---\nname: git-history-rewrite\ndescription: >-\n  Master git history manipulation: when modifying history is safe, git reset\u002Frebase alternatives, and maintaining history integrity. Use when user mentions git history, rewriting commits, git reset, amending commits, or when they want to clean up commit history. Triggers especially when user says \"clean up history\", \"rewrite git history\", \"git reset\", \"amend commit\", or \"squash commits\".\ncategory: coding\npriority: P2\ntrigger_patterns:\n  - \"clean up history\"\n  - \"rewrite git history\"\n  - \"git reset\"\n  - \"amend commit\"\n  - \"squash commits\"\n  - \"git history\"\n---\n\n# Git History Rewrite — Safe History Manipulation Framework\n\n## Overview\n\nGit-history-rewrite is a **behavioral specification skill** that encapsulates the judgment of **when modifying history is safe, which tool to use, and how to avoid breaking things**.\n\nThis skill embodies the experience of developers who've learned (sometimes painfully) that rewriting history is powerful but dangerous, and the key is knowing when it's appropriate.\n\n## Core Philosophy\n\n### The History Rewrite Golden Rules\n\n> **Rule 1: Never rewrite public\u002Fshared history**\n> **Rule 2: If you broke Rule 1, communicate immediately**\n\n```\n┌─────────────────────────────────────────────────────────────┐\n│                   HISTORY REWRITE SAFETY                       │\n│                                                               │\n│    SAFE: Local-only branches that haven't been shared       │\n│    ✓ Your feature branch                                      │\n│    ✓ Commits you haven't pushed                             │\n│    ✓ Branches that only you have                            │\n│                                                               │\n│    DANGEROUS: Shared or published branches                   │\n│    ✗ Main\u002Fdevelop branches                                   │\n│    ✗ Pushed feature branches                                 │\n│    ✗ Branches others have checked out                       │\n│    ✗ Any branch in a PR                                     │\n└─────────────────────────────────────────────────────────────┘\n```\n\n## Decision Framework\n\n### History Rewrite Tool Selection\n\n```\n┌─────────────────────────────────────────────────────────────┐\n│                    TOOL SELECTION                              │\n│                                                               │\n│  Want to...                 Use...              Safe if...   │\n│  ─────────                  ─────              ──────────   │\n│  Fix last commit message    git commit --amend  Not pushed   │\n│  Add file to last commit    git commit --amend  Not pushed   │\n│  Remove last commit         git reset          Not pushed   │\n│  Combine multiple commits   git rebase -i       Local only  │\n│  Remove commits entirely    git rebase -i       Local only  │\n│  Move branch to new base    git rebase          Local only  │\n│  Undo pushed changes        git revert           Always safe │\n└─────────────────────────────────────────────────────────────┘\n```\n\n### When Each Tool is Appropriate\n\n| Tool | Use When | Don't Use When |\n|------|----------|----------------|\n| `commit --amend` | Fix last commit message\u002Fadd forgotten file | Pushed commits |\n| `git reset` | Undo uncommitted changes, clean staging | Pushed commits |\n| `git rebase -i` | Squash\u002Ffixup\u002Freorder commits before PR | Pushed\u002Fshared branches |\n| `git revert` | Undo published changes safely | Simple local cleanup |\n| `git filter-branch` | Mass history changes | Almost never needed |\n\n## Behavioral Specification\n\n### Phase 1: Understanding git reset\n\n#### 1.1 Three Modes of Reset\n\n```bash\n# SOFT: Move branch pointer, keep changes staged\ngit reset --soft HEAD~1\n# Result: Last commit unstaged, changes ready to recommit\n\n# MIXED (default): Move branch pointer, unstaged\ngit reset HEAD~1\n# Result: Last commit unstaged and unstaged\n\n# HARD: Move branch pointer, DISCARD changes\ngit reset --hard HEAD~1\n# WARNING: This deletes work!\n```\n\n#### 1.2 Reset Decision Tree\n\n```\n                    ┌─ Did you push this commit?\n                    │   └─ YES → DON'T RESET\n                    │       └─ Use git revert instead\n                    │       └─ NO → Continue\n                    │\n                    └─ Do you want to keep the changes?\n                        └─ NO → git reset --hard (DANGEROUS!)\n                        └─ YES → Continue\n                                │\n                                └─ Do you want to recommit?\n                                    └─ YES → git reset --soft\n                                    └─ NO → git reset --mixed\n```\n\n### Phase 2: Interactive Rebase\n\n#### 2.1 Interactive Rebase Commands\n\n```bash\n# Clean up last N commits\ngit rebase -i HEAD~5\n\n# Commands available in interactive mode:\npick abc1234  Add user authentication      # Use commit as-is\nfixup def5678 Fix typo                     # Squash into previous, discard message\nsquash ghi9012 WIP                         # Squash into previous, keep messages\nreword jkl2345 Update readme               # Change commit message\ndrop mnop6789 WIP debugging                 # Remove commit entirely\nexec uvwx9012 npm test                     # Run command during rebase\n```\n\n#### 2.2 Common Rebase Scenarios\n\n```bash\n# Scenario 1: Squash commits into one\npick abc123 Add feature\nfixup def567 Fix typo\nfixup ghi890 Fix another typo\n# Result: One commit with all changes\n\n# Scenario 2: Reorder commits\npick abc123 Add feature A\npick def456 Add feature B\n# Can reorder to change order\n\n# Scenario 3: Edit commit message\npick abc123 Update readme\nreword abc123 Add better readme\n# Opens editor to change message\n\n# Scenario 4: Split a commit (advanced)\n# In rebase, mark commit as \"edit\"\n# Then git reset HEAD~\n# Then git add + git commit multiple times\n# Then git rebase --continue\n```\n\n### Phase 3: Safe History Cleanup\n\n#### 3.1 Before Cleanup Checklist\n\n```markdown\n## Pre-Cleanup Safety Check\n\n□ Is this branch local only?\n□ Has it been pushed to remote?\n□ Have others branched from this?\n□ Is there a PR open?\n\nIf ALL NO → Safe to rewrite\nIf ANY YES → DO NOT rewrite, consider alternatives\n```\n\n#### 3.2 Common Safe Cleanups\n\n```bash\n# 1. Fix the last commit message\ngit commit --amend -m \"fix(auth): correct typo in login validation\"\n\n# 2. Add forgotten file to last commit\ngit add forgotten-file.ts\ngit commit --amend --no-edit\n\n# 3. Combine commits on a feature branch\ngit rebase -i HEAD~3\n# Change 'pick' to 'fixup' for commits to combine\n\n# 4. Remove a commit entirely (local only!)\ngit rebase -i HEAD~5\n# Change 'pick' to 'drop' for commit to remove\n```\n\n### Phase 4: Handling History Rewrite Accidents\n\n#### 4.1 Recovery Options\n\n```bash\n# REFLOG is your safety net\ngit reflog\n# Shows all places HEAD has been\n# Format: HEAD@{N} - description\n\n# Recover a \"lost\" commit\ngit checkout abc1234  # The commit hash from reflog\n# Creates detached HEAD, can branch from here\ngit branch recovered-work\n\n# Or reset back to a reflog point\ngit reset --hard HEAD@{5}\n```\n\n#### 4.2 After Rewriting Pushed History\n\n```markdown\n## INCIDENT: Pushed History Rewritten\n\nIMMEDIATE ACTIONS:\n1. STOP - Don't push more changes\n2. ASSESS - Who might have this history?\n3. COMMUNICATE - Tell affected team members\n4. RECOVER - Help them get back to correct state\n\nPREVENTION:\n1. Always check if branch is shared before rewriting\n2. Use --force-with-lease instead of --force\n3. Prefer merge over rebase for shared branches\n```\n\n## Common Scenarios\n\n### Scenario 1: \"I need to clean up before PR\"\n\n```bash\n# BEFORE PR, clean up commits\ngit rebase -i HEAD~5\n\n# Typical cleanup in editor:\npick abc123 Add feature\nfixup def456 Fix typo in comment\nfixup ghi789 Fix typo in function name\ndrop jkl012 WIP debugging\ndrop mnop345 More debugging\n\n# Result: Clean history with 2-3 meaningful commits\n```\n\n### Scenario 2: \"I accidentally committed to main\"\n\n```bash\n# Oops! Committed to main instead of feature branch\n\n# Solution 1: Move to feature branch\ngit branch feature-temp          # Create branch from current main\ngit reset --hard origin\u002Fmain    # Reset main back\ngit checkout feature-branch       # Switch to feature\ngit merge feature-temp          # Merge the work\ngit branch -d feature-temp       # Clean up\n\n# Solution 2: If you haven't pushed\ngit reset --soft HEAD~1         # Uncommit but keep staged\ngit stash                        # Stash the changes\ngit checkout feature-branch      # Switch to feature\ngit stash pop                   # Get changes back\n```\n\n### Scenario 3: \"I need to undo a pushed commit\"\n\n```bash\n# DON'T: git reset (rewrites history)\n# DON'T: git rebase (rewrites history)\n\n# DO: Use git revert (safe, creates new commit)\ngit revert HEAD\n\n# This creates a NEW commit that undoes the change\n# Pushes the \"undo\" to shared history\n# Everyone can pull safely\n```\n\n## The History Rewrite Decision Checklist\n\n```\nHISTORY REWRITE DECISION CHECKLIST\n===================================\n\n□ 1. Is this history local only?\n  └─ YES → Rewrite may be safe\n  └─ NO → STOP, don't rewrite\n\n□ 2. Has this been pushed?\n  └─ YES → Use git revert instead\n  └─ NO → Continue\n\n□ 3. Is this a PR branch?\n  └─ YES → Coordinate with reviewers\n  └─ NO → Continue\n\n□ 4. Do others have this branch checked out?\n  └─ YES → Coordinate with them first\n  └─ NO → Continue\n\n□ 5. Have you created a backup?\n  └─ YES → Good!\n  └─ NO → git branch backup\u002Fbranch-name\n\n□ 6. Do you understand the tool you're using?\n  □ git reset --hard = PERMANENT deletion\n  □ git rebase -i = Interactive review\n  □ git revert = Safe undo\n\nTOOL SELECTION:\n□ commit --amend → Last commit, message\u002Fcontent fix\n□ git reset → Undo commits, keep\u002Fdon't keep changes\n□ git rebase -i → Multiple commits, reorder\u002Ffix\u002Fsquash\n□ git revert → Undo published changes safely\n```\n\n## Anti-Patterns\n\n### 1. Rewriting Pushed History\n\n```bash\n# DANGEROUS!\ngit push --force\n\n# If others have this history, you just broke their branches\n# Their commits now point to commits that don't exist\n\n# SAFER: --force-with-lease\ngit push --force-with-lease\n# Refuses if remote has commits you don't have\n# Still dangerous but slightly safer\n```\n\n### 2. Not Creating Backup\n\n```bash\n# BAD: No backup before risky operation\ngit reset --hard HEAD~5\n# 5 commits deleted...\n\n# GOOD: Create backup first\ngit branch backup-before-cleanup\ngit reset --hard HEAD~5\n# If something goes wrong, backup exists\n```\n\n### 3. Using Filter-Branch Unnecessarily\n\n```bash\n# OVERKILL for most cases\ngit filter-branch --tree-filter 'rm -f password.txt'\n\n# CONSIDER: git-filter-repo (newer, faster)\n# Or: Ask if you really need this\n```\n\n## History Rewrite Workflow Patterns\n\n### Pattern 1: Pre-PR Cleanup\n\n```bash\n# 1. Fetch latest\ngit fetch origin\n\n# 2. Rebase onto latest main\ngit rebase -i origin\u002Fmain\n# OR: git merge origin\u002Fmain if rebasing is complex\n\n# 3. Clean up during rebase\n# pick → use\n# fixup → combine, discard message\n# squash → combine, keep messages\n# drop → remove\n\n# 4. Push (may need --force-with-lease)\ngit push --force-with-lease origin feature-branch\n```\n\n### Pattern 2: Fixing a Mistake\n\n```bash\n# 1. If last commit not pushed\ngit commit --amend\n\n# 2. If commit from a few ago, not pushed\ngit rebase -i HEAD~3\n# Mark as 'reword' for message or 'fixup' for content\n\n# 3. If pushed commit needs undoing\ngit revert HEAD\ngit push\n```\n\n### Pattern 3: Recovering from Accident\n\n```bash\n# 1. Check reflog\ngit reflog\n\n# 2. Find the good state\ngit reflog | grep \"your-branch\"\n# abc1234 your-branch: commit: Feature X\n# def5678 your-branch: reset: to \"origin\u002F...\"\n\n# 3. Recover\ngit reset --hard abc1234\n```\n\n## Key Principles\n\n### 1. Public History is Sacred\n\nIf others have it, don't rewrite it. Use revert instead.\n\n### 2. Local History is Flexible\n\nYou own your local branches. Clean up before sharing.\n\n### 3. Backup Before Risky Operations\n\nCreate a branch or tag before `reset --hard` or complex rebase.\n\n### 4. Commit Messages Can Be Fixed\n\nUntil pushed, commit messages are editable. Do it before sharing.\n\n### 5. Reflog Saves Lives\n\nEven after a mistake, reflog can usually recover your work.\n\n## Understanding git reflog\n\n```bash\n# View reflog\ngit reflog\n\n# Output example:\n# abc1234 HEAD@{0}: reset: moving to HEAD~2\n# def5678 HEAD@{1}: commit: WIP feature\n# ghi9012 HEAD@{2}: commit: More WIP\n# jkl3456 HEAD@{3}: checkout: moving to feature\n\n# Recover to specific point\ngit checkout HEAD@{1}\n\n# Or reset\ngit reset --hard HEAD@{1}\n```\n\n## Relationship to Other Skills\n\n- `git-branch-strategy` — Branch decisions affect history\n- `git-rebase-safety` — Rebase is a form of history rewrite\n- `git-merge-resolution` — Alternative to rewriting\n- `git-commit` — Amending improves commit messages\n- `git-stash-management` — Stashing before risky operations\n","# Git History Rewrite — Safe History Manipulation Framework\n\n## Overview\n\nGit-history-rewrite is a **behavioral specification skill** that encapsulates the judgment of **when modifying history is safe, which tool to use, and how to avoid breaking things**.\n\nThis skill embodies the experience of developers who've learned (sometimes painfully) that rewriting history is powerful but dangerous, and the key is knowing when it's appropriate.\n\n## Core Philosophy\n\n### The History Rewrite Golden Rules\n\n> **Rule 1: Never rewrite public\u002Fshared history**\n> **Rule 2: If you broke Rule 1, communicate immediately**\n\n```\n┌─────────────────────────────────────────────────────────────┐\n│                   HISTORY REWRITE SAFETY                       │\n│                                                               │\n│    SAFE: Local-only branches that haven't been shared       │\n│    ✓ Your feature branch                                      │\n│    ✓ Commits you haven't pushed                             │\n│    ✓ Branches that only you have                            │\n│                                                               │\n│    DANGEROUS: Shared or published branches                   │\n│    ✗ Main\u002Fdevelop branches                                   │\n│    ✗ Pushed feature branches                                 │\n│    ✗ Branches others have checked out                       │\n│    ✗ Any branch in a PR                                     │\n└─────────────────────────────────────────────────────────────┘\n```\n\n## Decision Framework\n\n### History Rewrite Tool Selection\n\n```\n┌─────────────────────────────────────────────────────────────┐\n│                    TOOL SELECTION                              │\n│                                                               │\n│  Want to...                 Use...              Safe if...   │\n│  ─────────                  ─────              ──────────   │\n│  Fix last commit message    git commit --amend  Not pushed   │\n│  Add file to last commit    git commit --amend  Not pushed   │\n│  Remove last commit         git reset          Not pushed   │\n│  Combine multiple commits   git rebase -i       Local only  │\n│  Remove commits entirely    git rebase -i       Local only  │\n│  Move branch to new base    git rebase          Local only  │\n│  Undo pushed changes        git revert           Always safe │\n└─────────────────────────────────────────────────────────────┘\n```\n\n### When Each Tool is Appropriate\n\n| Tool | Use When | Don't Use When |\n|------|----------|----------------|\n| `commit --amend` | Fix last commit message\u002Fadd forgotten file | Pushed commits |\n| `git reset` | Undo uncommitted changes, clean staging | Pushed commits |\n| `git rebase -i` | Squash\u002Ffixup\u002Freorder commits before PR | Pushed\u002Fshared branches |\n| `git revert` | Undo published changes safely | Simple local cleanup |\n| `git filter-branch` | Mass history changes | Almost never needed |\n\n## Behavioral Specification\n\n### Phase 1: Understanding git reset\n\n#### 1.1 Three Modes of Reset\n\n```bash\n# SOFT: Move branch pointer, keep changes staged\ngit reset --soft HEAD~1\n# Result: Last commit unstaged, changes ready to recommit\n\n# MIXED (default): Move branch pointer, unstaged\ngit reset HEAD~1\n# Result: Last commit unstaged and unstaged\n\n# HARD: Move branch pointer, DISCARD changes\ngit reset --hard HEAD~1\n# WARNING: This deletes work!\n```\n\n#### 1.2 Reset Decision Tree\n\n```\n                    ┌─ Did you push this commit?\n                    │   └─ YES → DON'T RESET\n                    │       └─ Use git revert instead\n                    │       └─ NO → Continue\n                    │\n                    └─ Do you want to keep the changes?\n                        └─ NO → git reset --hard (DANGEROUS!)\n                        └─ YES → Continue\n                                │\n                                └─ Do you want to recommit?\n                                    └─ YES → git reset --soft\n                                    └─ NO → git reset --mixed\n```\n\n### Phase 2: Interactive Rebase\n\n#### 2.1 Interactive Rebase Commands\n\n```bash\n# Clean up last N commits\ngit rebase -i HEAD~5\n\n# Commands available in interactive mode:\npick abc1234  Add user authentication      # Use commit as-is\nfixup def5678 Fix typo                     # Squash into previous, discard message\nsquash ghi9012 WIP                         # Squash into previous, keep messages\nreword jkl2345 Update readme               # Change commit message\ndrop mnop6789 WIP debugging                 # Remove commit entirely\nexec uvwx9012 npm test                     # Run command during rebase\n```\n\n#### 2.2 Common Rebase Scenarios\n\n```bash\n# Scenario 1: Squash commits into one\npick abc123 Add feature\nfixup def567 Fix typo\nfixup ghi890 Fix another typo\n# Result: One commit with all changes\n\n# Scenario 2: Reorder commits\npick abc123 Add feature A\npick def456 Add feature B\n# Can reorder to change order\n\n# Scenario 3: Edit commit message\npick abc123 Update readme\nreword abc123 Add better readme\n# Opens editor to change message\n\n# Scenario 4: Split a commit (advanced)\n# In rebase, mark commit as \"edit\"\n# Then git reset HEAD~\n# Then git add + git commit multiple times\n# Then git rebase --continue\n```\n\n### Phase 3: Safe History Cleanup\n\n#### 3.1 Before Cleanup Checklist\n\n```markdown\n## Pre-Cleanup Safety Check\n\n□ Is this branch local only?\n□ Has it been pushed to remote?\n□ Have others branched from this?\n□ Is there a PR open?\n\nIf ALL NO → Safe to rewrite\nIf ANY YES → DO NOT rewrite, consider alternatives\n```\n\n#### 3.2 Common Safe Cleanups\n\n```bash\n# 1. Fix the last commit message\ngit commit --amend -m \"fix(auth): correct typo in login validation\"\n\n# 2. Add forgotten file to last commit\ngit add forgotten-file.ts\ngit commit --amend --no-edit\n\n# 3. Combine commits on a feature branch\ngit rebase -i HEAD~3\n# Change 'pick' to 'fixup' for commits to combine\n\n# 4. Remove a commit entirely (local only!)\ngit rebase -i HEAD~5\n# Change 'pick' to 'drop' for commit to remove\n```\n\n### Phase 4: Handling History Rewrite Accidents\n\n#### 4.1 Recovery Options\n\n```bash\n# REFLOG is your safety net\ngit reflog\n# Shows all places HEAD has been\n# Format: HEAD@{N} - description\n\n# Recover a \"lost\" commit\ngit checkout abc1234  # The commit hash from reflog\n# Creates detached HEAD, can branch from here\ngit branch recovered-work\n\n# Or reset back to a reflog point\ngit reset --hard HEAD@{5}\n```\n\n#### 4.2 After Rewriting Pushed History\n\n```markdown\n## INCIDENT: Pushed History Rewritten\n\nIMMEDIATE ACTIONS:\n1. STOP - Don't push more changes\n2. ASSESS - Who might have this history?\n3. COMMUNICATE - Tell affected team members\n4. RECOVER - Help them get back to correct state\n\nPREVENTION:\n1. Always check if branch is shared before rewriting\n2. Use --force-with-lease instead of --force\n3. Prefer merge over rebase for shared branches\n```\n\n## Common Scenarios\n\n### Scenario 1: \"I need to clean up before PR\"\n\n```bash\n# BEFORE PR, clean up commits\ngit rebase -i HEAD~5\n\n# Typical cleanup in editor:\npick abc123 Add feature\nfixup def456 Fix typo in comment\nfixup ghi789 Fix typo in function name\ndrop jkl012 WIP debugging\ndrop mnop345 More debugging\n\n# Result: Clean history with 2-3 meaningful commits\n```\n\n### Scenario 2: \"I accidentally committed to main\"\n\n```bash\n# Oops! Committed to main instead of feature branch\n\n# Solution 1: Move to feature branch\ngit branch feature-temp          # Create branch from current main\ngit reset --hard origin\u002Fmain    # Reset main back\ngit checkout feature-branch       # Switch to feature\ngit merge feature-temp          # Merge the work\ngit branch -d feature-temp       # Clean up\n\n# Solution 2: If you haven't pushed\ngit reset --soft HEAD~1         # Uncommit but keep staged\ngit stash                        # Stash the changes\ngit checkout feature-branch      # Switch to feature\ngit stash pop                   # Get changes back\n```\n\n### Scenario 3: \"I need to undo a pushed commit\"\n\n```bash\n# DON'T: git reset (rewrites history)\n# DON'T: git rebase (rewrites history)\n\n# DO: Use git revert (safe, creates new commit)\ngit revert HEAD\n\n# This creates a NEW commit that undoes the change\n# Pushes the \"undo\" to shared history\n# Everyone can pull safely\n```\n\n## The History Rewrite Decision Checklist\n\n```\nHISTORY REWRITE DECISION CHECKLIST\n===================================\n\n□ 1. Is this history local only?\n  └─ YES → Rewrite may be safe\n  └─ NO → STOP, don't rewrite\n\n□ 2. Has this been pushed?\n  └─ YES → Use git revert instead\n  └─ NO → Continue\n\n□ 3. Is this a PR branch?\n  └─ YES → Coordinate with reviewers\n  └─ NO → Continue\n\n□ 4. Do others have this branch checked out?\n  └─ YES → Coordinate with them first\n  └─ NO → Continue\n\n□ 5. Have you created a backup?\n  └─ YES → Good!\n  └─ NO → git branch backup\u002Fbranch-name\n\n□ 6. Do you understand the tool you're using?\n  □ git reset --hard = PERMANENT deletion\n  □ git rebase -i = Interactive review\n  □ git revert = Safe undo\n\nTOOL SELECTION:\n□ commit --amend → Last commit, message\u002Fcontent fix\n□ git reset → Undo commits, keep\u002Fdon't keep changes\n□ git rebase -i → Multiple commits, reorder\u002Ffix\u002Fsquash\n□ git revert → Undo published changes safely\n```\n\n## Anti-Patterns\n\n### 1. Rewriting Pushed History\n\n```bash\n# DANGEROUS!\ngit push --force\n\n# If others have this history, you just broke their branches\n# Their commits now point to commits that don't exist\n\n# SAFER: --force-with-lease\ngit push --force-with-lease\n# Refuses if remote has commits you don't have\n# Still dangerous but slightly safer\n```\n\n### 2. Not Creating Backup\n\n```bash\n# BAD: No backup before risky operation\ngit reset --hard HEAD~5\n# 5 commits deleted...\n\n# GOOD: Create backup first\ngit branch backup-before-cleanup\ngit reset --hard HEAD~5\n# If something goes wrong, backup exists\n```\n\n### 3. Using Filter-Branch Unnecessarily\n\n```bash\n# OVERKILL for most cases\ngit filter-branch --tree-filter 'rm -f password.txt'\n\n# CONSIDER: git-filter-repo (newer, faster)\n# Or: Ask if you really need this\n```\n\n## History Rewrite Workflow Patterns\n\n### Pattern 1: Pre-PR Cleanup\n\n```bash\n# 1. Fetch latest\ngit fetch origin\n\n# 2. Rebase onto latest main\ngit rebase -i origin\u002Fmain\n# OR: git merge origin\u002Fmain if rebasing is complex\n\n# 3. Clean up during rebase\n# pick → use\n# fixup → combine, discard message\n# squash → combine, keep messages\n# drop → remove\n\n# 4. Push (may need --force-with-lease)\ngit push --force-with-lease origin feature-branch\n```\n\n### Pattern 2: Fixing a Mistake\n\n```bash\n# 1. If last commit not pushed\ngit commit --amend\n\n# 2. If commit from a few ago, not pushed\ngit rebase -i HEAD~3\n# Mark as 'reword' for message or 'fixup' for content\n\n# 3. If pushed commit needs undoing\ngit revert HEAD\ngit push\n```\n\n### Pattern 3: Recovering from Accident\n\n```bash\n# 1. Check reflog\ngit reflog\n\n# 2. Find the good state\ngit reflog | grep \"your-branch\"\n# abc1234 your-branch: commit: Feature X\n# def5678 your-branch: reset: to \"origin\u002F...\"\n\n# 3. Recover\ngit reset --hard abc1234\n```\n\n## Key Principles\n\n### 1. Public History is Sacred\n\nIf others have it, don't rewrite it. Use revert instead.\n\n### 2. Local History is Flexible\n\nYou own your local branches. Clean up before sharing.\n\n### 3. Backup Before Risky Operations\n\nCreate a branch or tag before `reset --hard` or complex rebase.\n\n### 4. Commit Messages Can Be Fixed\n\nUntil pushed, commit messages are editable. Do it before sharing.\n\n### 5. Reflog Saves Lives\n\nEven after a mistake, reflog can usually recover your work.\n\n## Understanding git reflog\n\n```bash\n# View reflog\ngit reflog\n\n# Output example:\n# abc1234 HEAD@{0}: reset: moving to HEAD~2\n# def5678 HEAD@{1}: commit: WIP feature\n# ghi9012 HEAD@{2}: commit: More WIP\n# jkl3456 HEAD@{3}: checkout: moving to feature\n\n# Recover to specific point\ngit checkout HEAD@{1}\n\n# Or reset\ngit reset --hard HEAD@{1}\n```\n\n## Relationship to Other Skills\n\n- `git-branch-strategy` — Branch decisions affect history\n- `git-rebase-safety` — Rebase is a form of history rewrite\n- `git-merge-resolution` — Alternative to rewriting\n- `git-commit` — Amending improves commit messages\n- `git-stash-management` — Stashing before risky operations\n",{"name":5,"category":31,"priority":43,"description":7,"trigger_patterns":44},"P2",[45,46,47,48,26,49],"clean up history","rewrite git history","git reset","amend commit","git history","main","b9a52d8e27455bdad953d64928696d028223ea1b","skills\u002Fcoding\u002Fgit-history-rewrite","https:\u002F\u002Fgithub.com\u002FImaginerLabs\u002Fskill-manager","https:\u002F\u002Fgithub.com\u002FImaginerLabs","2026-04-18 16:27:13",{"source":8,"skillName":5,"commands":57,"prompt":67,"zipAvailable":68},[58,61,64],{"tool":59,"command":60},"npx","npx skills add ImaginerLabs\u002Fskill-manager --skill git-history-rewrite",{"tool":62,"command":63},"bunx","bunx skills add ImaginerLabs\u002Fskill-manager --skill git-history-rewrite",{"tool":65,"command":66},"pnpm","pnpm dlx skills add ImaginerLabs\u002Fskill-manager --skill git-history-rewrite","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FImaginerLabs\u002Fskill-manager\u002Fblob\u002Fmain\u002Fskills\u002Fcoding\u002Fgit-history-rewrite\u002FSKILL.md",true,[],[71,105,126,154,190,215],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":87,"publishedAt":38},"01M6QJCB2SD5KHC41ZDQC0GA1T","meeting-minutes","Generate concise, actionable meeting minutes for internal meetings. Includes metadata, attendees, agenda, decisions, action items (owner + due date), and follow-up steps.","https:\u002F\u002Fgithub.com\u002FImaginerLabs\u002Fskill-manager\u002Fblob\u002Fmain\u002Fskills\u002Fwriting\u002Fmeeting-minutes\u002FSKILL.md",[77,82],{"categoryNo":78,"categoryName":79,"taxonomyType":80,"taxonomyTypeDesc":81},"01JBSEEDCAT000000000000023","Skill与智能体开发","SCENARIO","使用场景",{"categoryNo":83,"categoryName":84,"taxonomyType":85,"taxonomyTypeDesc":86},"01JBSEEDCAT000000000000034","行政与办公人员","PROFESSION","适用职业",[88,89,90,91,92,93,94,95,96,29,73,50,97,98,99,100,101,102,103,104],"meeting minutes","meeting","minutes","writing","github","copilot","generate","decisions","meetings","agenda","actionable","concise","follow-up","tree","true","action","for",{"skillNo":106,"name":107,"nameZh":6,"description":108,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":109,"categories":110,"keywords":111,"publishedAt":38},"01M6QJC71RRGTGNNFEHJG6S20G","documentation-writer","Diátaxis Documentation Expert. An expert technical writer specializing in creating high-quality software documentation, guided by the principles and structure of the Diátaxis technical documentation authoring framework.","https:\u002F\u002Fgithub.com\u002FImaginerLabs\u002Fskill-manager\u002Fblob\u002Fmain\u002Fskills\u002Fwriting\u002Fdocumentation-writer\u002FSKILL.md",[],[112,113,114,91,92,93,115,116,117,118,119,120,50,121,122,123,124,101,102,125],"documentation","documentation writer","writer","https","quality","technical","technical writer","expert","documentation expert","structure","authoring","software","principles","high",{"skillNo":127,"name":128,"nameZh":6,"description":129,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":130,"categories":131,"keywords":139,"publishedAt":38},"01M6QJC0V3C7C4R9768J1AJYWY","doc-coauthoring","Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or similar documentation tasks.","https:\u002F\u002Fgithub.com\u002FImaginerLabs\u002Fskill-manager\u002Fblob\u002Fmain\u002Fskills\u002Fwriting\u002Fdoc-coauthoring\u002FSKILL.md",[132,135,136],{"categoryNo":133,"categoryName":134,"taxonomyType":80,"taxonomyTypeDesc":81},"01JBSEEDCAT000000000000018","写作与文案",{"categoryNo":78,"categoryName":79,"taxonomyType":80,"taxonomyTypeDesc":81},{"categoryNo":137,"categoryName":138,"taxonomyType":85,"taxonomyTypeDesc":86},"01JBSEEDCAT000000000000036","内容创作者",[140,141,91,142,143,112,144,145,146,147,148,149,50,150,151,122,152,153,101,104],"doc coauthoring","doc","workflow","official","tasks","decision","write","context","proposals","guide","refine","iteration","trigger","co",{"skillNo":155,"name":156,"nameZh":6,"description":157,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":158,"categories":159,"keywords":170,"publishedAt":38},"01M6QJBJ0YPVEWGEXZH3PJRRTT","code-review-workflow","Executes comprehensive 4-phase code review: basic review, quality check, bundle analysis, and test coverage. Should be used when the user mentions comprehensive code review, checking code quality, or reviewing staged changes with multi-phase analysis. This is the comprehensive review workflow, distinct from focused skills like frontend-code-review, staged-code-review, or code-change-test-designer.","https:\u002F\u002Fgithub.com\u002FImaginerLabs\u002Fskill-manager\u002Fblob\u002Fmain\u002Fskills\u002Ftesting\u002Fcode-review-workflow\u002FSKILL.md",[160,163,166,167],{"categoryNo":161,"categoryName":162,"taxonomyType":80,"taxonomyTypeDesc":81},"01JBSEEDCAT000000000000007","代码审查",{"categoryNo":164,"categoryName":165,"taxonomyType":80,"taxonomyTypeDesc":81},"01JBSEEDCAT000000000000008","测试与质量",{"categoryNo":78,"categoryName":79,"taxonomyType":80,"taxonomyTypeDesc":81},{"categoryNo":168,"categoryName":169,"taxonomyType":85,"taxonomyTypeDesc":86},"01JBSEEDCAT000000000000030","开发工程师",[171,172,142,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189],"code review","review","code","code review workflow","testing","frontend","test","change","code quality","code-review","analysis","check","coverage","quality check","basic","multi","comprehensive code review","with","phase",{"skillNo":191,"name":192,"nameZh":6,"description":193,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":194,"categories":195,"keywords":205,"publishedAt":38},"01M6QJB7XNHV3VEEQF4W7FMWF6","code-change-test-designer","Analyzes code changes and designs comprehensive test cases. Reads diffs, summarizes capability changes, and designs test cases covering main flows and edge cases. Should be used when the user mentions test coverage, designing tests for code changes, or analyzing diff\u002Fcommit for testing purposes. Distinguished from code-review-workflow which provides comprehensive review, this skill focuses on test case design for code changes.","https:\u002F\u002Fgithub.com\u002FImaginerLabs\u002Fskill-manager\u002Fblob\u002Fmain\u002Fskills\u002Ftesting\u002Fcode-change-test-designer\u002FSKILL.md",[196,197,200,201,202],{"categoryNo":164,"categoryName":165,"taxonomyType":80,"taxonomyTypeDesc":81},{"categoryNo":198,"categoryName":199,"taxonomyType":80,"taxonomyTypeDesc":81},"01JBSEEDCAT000000000000015","视觉设计",{"categoryNo":78,"categoryName":79,"taxonomyType":80,"taxonomyTypeDesc":81},{"categoryNo":168,"categoryName":169,"taxonomyType":85,"taxonomyTypeDesc":86},{"categoryNo":203,"categoryName":204,"taxonomyType":85,"taxonomyTypeDesc":86},"01JBSEEDCAT000000000000032","设计师",[177,178,173,206,207,175,208,209,142,37,180,210,183,211,50,212,213,214,104,189],"designer","code change test designer","design","diffs","edge","diff","tests","flows","which",{"skillNo":216,"name":217,"nameZh":6,"description":218,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":219,"categories":220,"keywords":222,"publishedAt":38},"01M6QJB195WD7DCJWDMKWKB29S","skill-creator","Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.","https:\u002F\u002Fgithub.com\u002FImaginerLabs\u002Fskill-manager\u002Fblob\u002Fmain\u002Fskills\u002Fmeta-skills\u002Fskill-creator\u002FSKILL.md",[221],{"categoryNo":78,"categoryName":79,"taxonomyType":80,"taxonomyTypeDesc":81},[223,224,225,226,143,227,228,229,230,231,181,232,233,234,50,235,236,101,104,217],"skill creator","creator","performance","run evals","variance analysis","create","run","benchmark","Meta","improve","edit","evals","optimize","existing skill"]