git-clean-history

Rewrite a feature branch onto a clean branch off main with narrative commits.

Updated Aug 12, 2018
One-click install
npx skills add https://github.com/ivanov-i/dots --skill git-clean-history-ivanov-i
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: git-clean-history
Source: https://github.com/ivanov-i/dots/tree/main/codex/skills/git-clean-history
Command: npx skills add https://github.com/ivanov-i/dots --skill git-clean-history-ivanov-i

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Rewrites the current feature branch history onto a new clean branch off main with a readable, narrative commit history.

Core Features & Use Cases

  • Create a new branch off main, default naming as {source_branch}-clean unless overridden by the user
  • Break the work into logical, review-friendly commits with clear messages
  • Ensure the final state exactly matches the source branch while presenting a clean history for reviews
  • Use this workflow to prepare pull requests that require a tidy, understandable history

Quick Start

Ask the AI to reimplement the current feature branch on a clean branch off main with a narrative commit history.

Frequently Asked Questions about git-clean-history

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

FAQPage Schema
How do I clean up a messy git branch history before creating a pull request?

You can clean up a messy git branch history by rewriting your feature branch onto a new branch created from main, reproducing your changes as logical, narrative commits with clear messages. This ensures the final state matches your source branch exactly while presenting a tidy, reviewer-friendly commit history.

What's the best way to rewrite feature branch commits into a reviewer-friendly narrative?

The best way to rewrite feature branch commits into a reviewer-friendly narrative is to create a new branch off main and reproduce your changes commit by commit with meaningful, descriptive messages, validating that the final tree state exactly matches your original source branch.

Can I prepare a clean git history for code review without losing my current branch state?

Yes, you can prepare a clean git history for code review without losing your current branch state. The process creates a new branch from main with a clean commit history and validates that the final state exactly matches your source branch, leaving your original branch untouched.

When do I need to rewrite commit history for a pull request?

You need to rewrite commit history for a pull request when your feature branch contains messy, incremental, or hard-to-follow commits that would make code review difficult. Rewriting onto a clean branch off main produces a readable, narrative commit history that helps reviewers understand your changes logically.

Does rewriting git history onto a clean branch guarantee the final code matches the original?

Yes, rewriting git history onto a clean branch validates that the final state exactly matches the source branch. The process reproduces your changes commit by commit on a new branch from main, ensuring the code outcome is identical while the commit history becomes clean and reviewer-friendly.

How do I name the new branch when cleaning up git commit history?

When cleaning up git commit history, the new branch is named using the pattern {source_branch}-clean by default. You can override this naming convention if needed, allowing you to maintain a consistent naming scheme across your repository while preparing a tidy branch for pull request review.