Skip to content

akirak/squasher

Repository files navigation

Squasher for Auto-Committed Git Repositories

https://img.shields.io/badge/cachix-akirak-blue.svg

This is a command line program that addresses a very particular need: squash Git commits that are automatically created (e.g. using git-auto-commit-mode for Emacs). It squashes a consecutive sequence of commits that have the same commit message into one commit. It also checks the author time of each commit, so if a commit is not authored within a certain duration (e.g. three hours) since the first commit of the sequence, it is not squashed, even if it has the same commit message.

Squashing is applied to commits between the head and its remote branch (i.e. origin/BRANCH unless the branch has a specific remote).

This is useful for keeping the history less messy, while frequently backing up changes to the Git repository.

Installation

It is a Go program, so you can build and install the program using Go.

Alternatively, you can use Nix with flakes enabled to run the program:

nix run github:akirak/squasher -- --help

Usage

Synopsis:

squasher [--base SHA] [--hours N] [DIR]

It takes an optional positional argument, which should be a path to a Git repository. By default, it is the current repository.

If --base is set, squashing starts from the commit instead of origin/BRANCH. You must give a full hash of a commit.

--hours option specifies the duration threshold in hours.

It rewrites the history of the head branch of a Git repository, so please use it with caution. As a safety net, it checks the status of the repository and aborts the operation if it is not clean.

To automate squashing, you can create a pre-push hook or your Git repository.

About

Squash consecutive Git commits

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published