Skip to content

Ian729/git-squash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

git-squash

A simple and powerful Git plugin to squash your commits before creating a Pull Request.

This tool provides a unified interface to squash commits:

  • By base branch name (e.g., main, master)
  • By number of recent commits
  • By specific commit SHA

πŸš€ Installation

  1. Download the git-squash script and save it to a directory in your $PATH, e.g.:

    curl -o ~/bin/git-squash https://raw.githubusercontent.com/Ian729/git-squash/main/git-squash
    chmod +x ~/bin/git-squash
  2. Ensure the directory is in your $PATH. Add this to your .bashrc / .zshrc if needed:

    export PATH="$HOME/bin:$PATH"

Usage

git squash <base-branch>
git squash <number-of-commits>
git squash --sha <commit-sha>

Examples

βœ… Squash all commits made since branching from main:

git squash main

βœ… Squash the last 3 commits:

git squash 3

βœ… Squash all commits made since a specific commit:

git squash --sha <commit-sha>

Note

  • This tool uses git reset --soft, preserving your working directory and staging area.

  • After squashing, use git push --force-with-lease to update the remote branch:

    git push --force-with-lease
  • Default commit message is Squashed commit, but you can provide a custom message during the prompt.

πŸ› οΈ Why use git-squash?

  • Keep your PR history clean.

  • Avoid git rebase -i complexity in simple squash workflows.

  • Fast, scriptable, and beginner-friendly.

πŸ“„ License

MIT License

About

A simple and powerful Git plugin to squash your commits before creating a Pull Request.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages