Skip to main content

Automatically squash git changes back into historical commits

Project description

git-autosquash

Tests Documentation PyPI version Python 3.12+

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.

git-autosquash Interactive TUI

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/

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

git_autosquash-1.0.0.tar.gz (83.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

git_autosquash-1.0.0-py3-none-any.whl (98.0 kB view details)

Uploaded Python 3

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

Hashes for git_autosquash-1.0.0.tar.gz
Algorithm Hash digest
SHA256 07c634c7cc95815b10d699a8c089b8fc70622fb77049c60337521f8090a683ff
MD5 a6c5ed59299519f3aed8b40dd2e967cb
BLAKE2b-256 c254cf4b8e4cb9b55aa5b11a390e34a675f22bc4c1ca5439aac23707967c63ea

See more details on using hashes here.

Provenance

The following attestation bundles were made for git_autosquash-1.0.0.tar.gz:

Publisher: release.yml on andrewleech/git-autosquash

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for git_autosquash-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 42d816a28f618fdc6dd3e697288895c69549be512db7cc99a926e2da6837d592
MD5 41174f5884cf3128fd54958f7d67a645
BLAKE2b-256 f3fe6712f3c6831c85598ac20978908f5bcf064780d9e74235784d1402cf5c24

See more details on using hashes here.

Provenance

The following attestation bundles were made for git_autosquash-1.0.0-py3-none-any.whl:

Publisher: release.yml on andrewleech/git-autosquash

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page