gt squash¶
Squash commits in the current branch.
Usage¶
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:
Squash Last N Commits¶
With Custom Message¶
Behavior¶
- Identifies commits to squash
- Creates a single commit with combined changes
- 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
Related Commands¶
gt modify- Amend single commitgt fold- Fold changes into previous commitgt restack- Update child branches