Skip to content

gt squash

Squash commits in the current branch.

Usage

gt squash [OPTIONS]

Options

Option Description
-m, --message <msg> Message for squashed commit
-n, --count <n> Number of commits to squash
--all Squash all commits since parent

Examples

Squash All Commits

Squash all commits in the current branch into one:

gt squash --all

Squash Last N Commits

gt squash -n 3

With Custom Message

gt squash --all -m "Feature: Add authentication"

Behavior

  1. Identifies commits to squash
  2. Creates a single commit with combined changes
  3. Updates the branch HEAD

Rebasing Required

After squashing, run gt restack to update any child branches.

When to Use

  • Before submitting a PR to clean up WIP commits
  • To combine related commits into logical units
  • To simplify history before landing