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-0.1.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-0.1.0-py3-none-any.whl (98.2 kB view details)

Uploaded Python 3

File details

Details for the file git_autosquash-0.1.0.tar.gz.

File metadata

  • Download URL: git_autosquash-0.1.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-0.1.0.tar.gz
Algorithm Hash digest
SHA256 051186ab79a0b450edabdb462034b723cea40d8cf07746eebae659a738a2ab41
MD5 463287c0bc6157924c48e88082459dfd
BLAKE2b-256 b0bf4c15e878ebadfd7d3417153a0ff995a4c705dc72f4a19c3d91fb6c7b3192

See more details on using hashes here.

Provenance

The following attestation bundles were made for git_autosquash-0.1.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-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: git_autosquash-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 98.2 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-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fa4afa7d01cf95bf4396256af55f1e58ce6127b23055485af86bac93079160b6
MD5 66601523e85c4f152e4d1103e7572741
BLAKE2b-256 3b891def89f1fd6ac0615acae3ceb432e3a5b9df1afc3382c27bde59db095b8e

See more details on using hashes here.

Provenance

The following attestation bundles were made for git_autosquash-0.1.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