Skip to content
Back to skills

Git History Cleanup

ASecurity

Turns a noisy branch of wip and fixup commits into a short, logical series with interactive rebase, with a backup and a tree-equality check.

  • 3 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added November 15, 2026
ai-agentsgit

Security analysis

A100/100

Scanned November 15, 2026

npx -y skills add workspace-templates/ai-agent-templates --skill git-history-cleanup --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Git History Cleanup?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Git History Cleanup
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/workspace-templates-git-history-cleanup/badge)](https://www.skillsdirectory.com/skills/workspace-templates-git-history-cleanup)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: git-history-cleanup
description: Turns a noisy branch of wip and fixup commits into a short, logical series with interactive rebase, with a backup and a tree-equality check.
---

# Git history cleanup

Rewrite only unpublished history, and prove the end result is identical.

## Steps

1. Check what you are about to rewrite: `git status` must be clean, and `git log origin/<branch>..HEAD` shows the unpushed commits. If the branch is already pushed and others may have it, stop and ask first.
2. Make a backup: `git branch backup/<branch>-before-cleanup`. Record the tree: `git rev-parse HEAD^{tree}`.
3. Read the whole range with `git log --stat --reverse <base>..HEAD` and design the target series on paper: usually 3 to 7 commits, ordered so each one builds (refactor, then behavior, then tests, then docs).
4. Rebase without an editor prompt. Write the rebase plan yourself and pass it with `GIT_SEQUENCE_EDITOR` (for example a small script, or `git commit --fixup` followed by `git rebase -i --autosquash <base>`). Use `reword` for messages, `fixup` to fold, `edit` to split a commit with `git reset HEAD^` and staged hunks.
5. Messages: imperative subject under 72 characters, a blank line, then why the change was made. No "wip", no ticket-only subjects.
6. After every `edit` stop, run the build and the fast tests so each commit stands.
7. Verify: `git rev-parse HEAD^{tree}` must equal the recorded tree. If it differs, the rewrite changed code: reset to the backup and retry.

## Rules

- Never rewrite `main` or any shared branch. Never force-push; tell the user to use `git push --force-with-lease` themselves.
- If the rebase conflicts, resolve carefully or abort with `git rebase --abort`.

## Report

Old and new commit lists, and confirmation that the trees match.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.