Automatically squash git changes back into historical commits
Project description
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.
What It Does
- Analyzes your working directory changes using git blame
- Maps each change to the commit that last modified those lines
- Presents an interactive interface for review and approval
- Executes git rebase to squash changes into target commits
- Maintains clean, logical git history
Why You Need It
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 noisy cleanup commits, git-autosquash pushes each fix back to the commit that originally introduced the code.
Before: Messy history with fix commits
* fix lint errors in auth module
* address PR feedback on validation
* update tests for new API
* feat: implement user authentication
* feat: add input validation
* feat: update user API
After: Clean history with integrated improvements
* feat: implement user authentication (includes lint fixes)
* feat: add input validation (includes PR feedback)
* feat: update user API (includes test updates)
Installation
# Recommended: Install with uv (fastest, modern Python package manager)
uv tool install git-autosquash
# Or with pipx for isolated environment
pipx install git-autosquash
# Or with pip
pip install git-autosquash
Usage
# Interactive mode (default): Review and approve changes in TUI
git-autosquash
# Auto-accept mode: Skip TUI for high-confidence targets
git-autosquash --auto-accept
# Dry-run mode: Preview what would be done without making changes
git-autosquash --auto-accept --dry-run
# Line-by-line precision mode
git-autosquash --line-by-line
How It Works
git-autosquash uses git blame analysis to trace each modified line back to its originating commit, then presents an interactive interface for reviewing and approving the proposed squash targets.
For complete documentation, architecture details, and advanced usage patterns, see: https://andrewleech.github.io/git-autosquash/
Working Tree State Handling
git-autosquash intelligently handles different working tree states:
- Clean working tree: Processes the HEAD commit for splitting up recent changes
- Staged changes only: Processes staged changes directly (no stashing needed)
- Unstaged changes only: Processes unstaged changes directly (no stashing needed)
- Both staged and unstaged: Temporarily stashes unstaged changes, processes staged changes, then restores unstaged changes
This smart handling ensures you can run git-autosquash at any time without losing work, while processing the most appropriate set of changes for your current workflow.
Key Features
- Smart Targeting: git blame analysis identifies logical target commits
- Interactive TUI: Rich terminal interface with diff previews
- Safety First: All changes require explicit approval
- Automatic Rollback: Full git reflog integration for recovery
- Conflict Resolution: Clear guidance when merge conflicts occur
- Multiple Modes: Interactive, auto-accept, and dry-run options
Documentation
Complete documentation: https://andrewleech.github.io/git-autosquash/
- Getting Started - First session walkthrough
- CLI Reference - All command-line options
- Advanced Usage - Complex workflows and edge cases
- Development Guide - Contributing and development setup
Use Cases
- Code review feedback distribution
- Lint and formatting fix integration
- Test update consolidation
- Documentation synchronization
- Security patch application
- Refactoring optimization placement
Status
Production-ready with full test coverage. All core functionality implemented and actively maintained.
Contributing
See Development Guide for setup, testing, and contribution guidelines.
Support
- Issues: GitHub Issues
- Documentation: https://andrewleech.github.io/git-autosquash/
- Discussions: GitHub Discussions
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file git_autosquash-1.0.0.tar.gz.
File metadata
- Download URL: git_autosquash-1.0.0.tar.gz
- Upload date:
- Size: 83.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07c634c7cc95815b10d699a8c089b8fc70622fb77049c60337521f8090a683ff
|
|
| MD5 |
a6c5ed59299519f3aed8b40dd2e967cb
|
|
| BLAKE2b-256 |
c254cf4b8e4cb9b55aa5b11a390e34a675f22bc4c1ca5439aac23707967c63ea
|
Provenance
The following attestation bundles were made for git_autosquash-1.0.0.tar.gz:
Publisher:
release.yml on andrewleech/git-autosquash
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
git_autosquash-1.0.0.tar.gz -
Subject digest:
07c634c7cc95815b10d699a8c089b8fc70622fb77049c60337521f8090a683ff - Sigstore transparency entry: 758101670
- Sigstore integration time:
-
Permalink:
andrewleech/git-autosquash@2a68e3ed94f213b3fab99ca1eb5f5ccd4b84d34c -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/andrewleech
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@2a68e3ed94f213b3fab99ca1eb5f5ccd4b84d34c -
Trigger Event:
push
-
Statement type:
File details
Details for the file git_autosquash-1.0.0-py3-none-any.whl.
File metadata
- Download URL: git_autosquash-1.0.0-py3-none-any.whl
- Upload date:
- Size: 98.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42d816a28f618fdc6dd3e697288895c69549be512db7cc99a926e2da6837d592
|
|
| MD5 |
41174f5884cf3128fd54958f7d67a645
|
|
| BLAKE2b-256 |
f3fe6712f3c6831c85598ac20978908f5bcf064780d9e74235784d1402cf5c24
|
Provenance
The following attestation bundles were made for git_autosquash-1.0.0-py3-none-any.whl:
Publisher:
release.yml on andrewleech/git-autosquash
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
git_autosquash-1.0.0-py3-none-any.whl -
Subject digest:
42d816a28f618fdc6dd3e697288895c69549be512db7cc99a926e2da6837d592 - Sigstore transparency entry: 758101683
- Sigstore integration time:
-
Permalink:
andrewleech/git-autosquash@2a68e3ed94f213b3fab99ca1eb5f5ccd4b84d34c -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/andrewleech
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@2a68e3ed94f213b3fab99ca1eb5f5ccd4b84d34c -
Trigger Event:
push
-
Statement type: