GitButler ⧓

Commands
>_

but squash

Squash commits, branches, or changes.

Squash is flexible in the ways it can move changes around. It can

  • Squash commits into other commits
  • Squash branches into commits
  • Move changes between commits
  • Amend uncommitted changes into a commit
  • Uncommit commits
  • Uncommit changes in commits
  • Uncommit branches

If no message-related flag is passed when squashing commits or branches, an editor may be opened where the new message can be composed; other squashes keep the target's message.

For more details about CLI IDs, see but help cli-ids.

Usage: but squash [SOURCES] [OPTIONS]

Arguments

  • <SOURCES> — The sources to squash, all of one kind.

Commits: squashed into the target. Branches: every commit on them is squashed into the target and the branches are removed; with no target and exactly one branch, that branch is squashed into a single commit. Uncommitted files or hunks, or @ for all of them: squashed into the target. Committed files and hunks from one commit: moved into the target.

A target of @ uncommits the sources instead. With --target and no sources, the uncommitted area of the checkout but runs in is used: @, or a linked worktree's.

Options

  • -m, --message <MESSAGE> — The message to use for the new commit.

Can be supplied any number of times, each value being appended to the preceding ones with a blank line in between. Without a message flag, squashing commits or branches opens the editor in a terminal; a non-interactive run skips the editor.

This cannot be used when TARGET is the uncommitted area (@).

  • --no-message — Create the commit without a message.

This cannot be used when TARGET is the uncommitted area (@).

  • -F, --file <FILE> — Read the message for the new commit from FILE, or from stdin when FILE is -.

This cannot be used when TARGET is the uncommitted area (@).

  • -u, --use-target-message — Use the message of the target.

The message of the source(s) will be discarded.

This cannot be used when TARGET is the uncommitted area (@).

  • --use-source-message — Use the message of the source(s).

The message of the target will be discarded.

Cannot be used if <SOURCES> are not committed, if TARGET is the uncommitted area (@), or if moving committed changes between commits.

  • -t, --target <TARGET> — The target to squash into.

If TARGET is a commit the sources will be added to the commit.

If TARGET is a branch the sources will be added to that branch's newest commit (its tip).

If TARGET is the uncommitted area (@) the sources will be uncommitted. A commit owned by a worktree uncommits into that worktree's area instead, named by its ID (<id>:@).

  • --allow-merged — Allow targeting branches and commits that are already merged upstream.

By default, mutations refuse to touch history that has landed in the target branch, since the results tend to conflict on the next but pull.

Last updated on

On this page

Edit on GitHubGive us feedback