GitButler ⧓

Commands
>_

but commit

Create a commit.

By default, all uncommitted changes of the checkout but runs in are included in the commit: the main worktree's, or a linked worktree's when run from inside one. This can be controlled with change flags such as --empty and --interactive, or by providing CHANGES as positional arguments.

Run from a linked worktree, or given changes from one, the commit is placed at the tip of that worktree's branch. Otherwise, if there are no branches applied, a new branch is created for the commit. If there is only one stack of branches applied, the commit is placed at the tip of that stack. Otherwise, the targeting flags --above, --below and --branch control where the commit is placed. --above and --below are mutually exclusive; combine either with --branch to name a new branch when targeting a branch.

The commit is expected to have a commit message unless --no-message is provided. If none of --no-message, --message or --file is provided, the user's preferred editor is opened to input a message.

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

Usage: but commit [CHANGES] [OPTIONS]

Arguments

  • <CHANGES> — The files or hunks to commit, by CLI ID from but diff.

If omitted, everything uncommitted in the checkout but runs in is committed.

Options

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

Can be supplied any amount of times, each value being appended to the preceding ones with a blank line in between. Without -m, -F or --no-message, a terminal opens the editor and a non-interactive run commits with an empty message.

  • --no-message — Create the commit without a message
  • -F, --file <FILE> — Read the commit message from FILE, or from stdin when FILE is -
  • -b, --branch <BRANCH> — Place the commit on the branch BRANCH.

With --above or --below, name the new branch created relative to the target branch. The name must not already exist; omit it for a generated name. Cannot be combined with commit or worktree targets.

Otherwise, if BRANCH does not exist, it is created as an unstacked branch. If BRANCH is omitted, an unstacked branch with a generated name is created.

If BRANCH is a worktree or a branch checked out in one, the commit is placed on the tip of that worktree's branch.

Attempting to place a commit on a branch that exists but is not applied is an error.

  • -A, --above <BRANCH_OR_COMMIT> — Place the commit above BRANCH_OR_COMMIT, which must be an applied branch or commit.

If BRANCH_OR_COMMIT is a commit, the new commit is placed on the same branch as the targeted commit.

If BRANCH_OR_COMMIT is a branch, the new commit is placed on a new branch above the targeted branch. Use --branch <NAME> to name it; otherwise a name is generated.

  • -B, --below <BRANCH_OR_COMMIT> — Place the commit below BRANCH_OR_COMMIT, which must be an applied branch or commit.

If BRANCH_OR_COMMIT is a commit, the new commit is placed on the same branch as the targeted commit.

If BRANCH_OR_COMMIT is a branch, the new commit is placed on a new branch below the targeted branch. Branches are treated as buckets, meaning that "below a branch" is treated as below the oldest ancestor on that branch. Use --branch <NAME> to name the new branch; otherwise a name is generated.

If BRANCH_OR_COMMIT is a worktree, the new commit is placed on the tip of the branch that worktree has checked out.

  • --empty — Create an empty commit even when there are changes
  • -i, --interactive — Open the TUI to interactively select what to commit
  • --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.

  • -s, --switch — Switch to the target branch instead of remaining in the GitButler workspace

Last updated on

On this page

Edit on GitHubGive us feedback