Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/akirak/squasher
Squash consecutive Git commits
https://github.com/akirak/squasher
auto-commit git
Last synced: 7 days ago
JSON representation
Squash consecutive Git commits
- Host: GitHub
- URL: https://github.com/akirak/squasher
- Owner: akirak
- License: mit
- Created: 2022-04-25T17:20:50.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-10-21T04:40:03.000Z (17 days ago)
- Last Synced: 2024-10-21T07:37:25.508Z (17 days ago)
- Topics: auto-commit, git
- Language: Go
- Homepage:
- Size: 52.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.org
- License: LICENSE
Awesome Lists containing this project
README
* Squasher for Auto-Committed Git Repositories
[[https://akirak.cachix.org][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 [[https://github.com/ryuslash/git-auto-commit-mode][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:
#+begin_src sh
nix run github:akirak/squasher -- --help
#+end_src
** Usage
Synopsis:#+begin_src sh
squasher [--base SHA] [--hours N] [DIR]
#+end_srcIt 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.