git-autosquash¶
Automatically squash changes back into historical commits where they belong.
git-autosquash eliminates "cleanup" commits by analyzing git blame to determine which historical commits should receive your current changes. Instead of accumulating "fix lint", "address PR feedback", or "update tests" commits, it distributes improvements back to their logical origin points.

Common scenario: You're working on a feature branch and need to address code review feedback, fix lint errors, or update tests across multiple files. Instead of creating cleanup commits, git-autosquash pushes each fix back to the commit that originally introduced the code.
Key Features¶
- Smart Targeting: Uses git blame to find commits where code was last modified
- Interactive TUI: Terminal interface with diff viewer and approval controls
- Safety First: All changes require explicit user approval
- Conflict Resolution: Clear guidance when merge conflicts occur during rebase
- Progress Tracking: Real-time feedback with detailed commit summaries
- Automatic Rollback: Repository restored to original state on errors
Quick Start¶
Installation¶
Basic Usage¶
- Make changes to your codebase
- Run analysis:
- Review proposed hunk → commit mappings in TUI
- Approve changes to squash back into target commits
- git-autosquash performs the interactive rebase
How It Works¶
graph TD
A[Working Directory Changes] --> B[Parse Git Diff into Hunks]
B --> C[Run Git Blame Analysis]
C --> D[Find Target Commits for Each Hunk]
D --> E[Interactive TUI Approval]
E --> F[Group Hunks by Target Commit]
F --> G[Execute Interactive Rebase]
G --> H[Distribute Changes to History]
E -.-> I[Cancel/Abort]
G -.-> J[Conflict Resolution]
J -.-> K[User Fixes Conflicts]
K --> G
Use Cases¶
- Code review feedback distribution
- Lint and formatting fix integration
- Test update consolidation
- Documentation synchronization
- Security patch application
- Refactoring optimization placement
Safety Features¶
- Default rejection: All changes start unapproved, require explicit user consent
- Conflict detection: Clear guidance when rebase conflicts occur
- Automatic rollback: Repository restored to original state on errors or interruption
- Branch validation: Only works on feature branches with clear merge-base
- Stash management: Safely handles mixed staged/unstaged states
Next Steps¶
- Installation Guide - Detailed setup instructions
- Getting Started - Your first git-autosquash workflow
- Basic Workflow - Common usage patterns
- CLI Reference - All command-line options
- Examples - Real-world scenarios and solutions
Contributing¶
- Development Guide - Set up development environment
- Architecture Overview - Understand the codebase
- Testing Guide - Run and write tests