View as Markdown

Updating Stacks

Amend, reorder, add, or remove commits in your stack.

Keys
actions.dismiss_reviews

After pushing a stack, you’ll need to make changes: responding to review feedback, adding commits, rearranging order, or squashing.

In all cases, the workflow is the same: edit your stack locally, then run mergify stack push to sync with GitHub.

Each editing command accepts a commit as either a short SHA or a Change-Id prefix. Most of them also support --dry-run (-n) to print the plan without touching your branch. The stack CLI reference has the full argument list for each one.

mergify stack push rebases your branch on its base branch before pushing, but holds the rebase back when it would cost you something. An approval is the first case, when the rebase could dismiss it: by changing a commit’s diff, or because a Mergify dismiss_reviews rule dismisses reviews on every push. A rebase that changes no commit’s diff goes through, and the push says the approvals are kept. The bottom PR sitting in a merge queue is the second, approved or not, because the force-push would take that PR out of the queue.

Two things rebase anyway. A real merge conflict between the bottom PR and the base branch overrides both cases, since a PR that can’t merge is worth neither the approval nor the place in the queue. So does a commit left in your branch after its PR merged: the rebase is what drops it. Pass --force-rebase to rebase regardless and accept both the dismissals and the lost place in the queue, or --skip-rebase (-R) to never rebase.

Make your changes, then amend:

Terminal windowbash
git add src/api/users.py
git commit --amend

The Change-Id is preserved automatically. Then push:

Terminal windowbash
mergify stack push

Only that commit’s PR is updated, unless the push rebases the stack on a newer base branch.

To modify a commit that isn’t at the top of your branch, point mergify stack edit at it. Pass a short SHA or Change-Id prefix and the rebase pauses on that commit:

Terminal windowbash
mergify stack edit a1b2c3d

Git stops at the target so you can make changes:

Terminal windowbash
# Make your changes
git add src/models/user.py
git commit --amend
git rebase --continue

Then push:

Terminal windowbash
mergify stack push

A push updates each PR whose commit got a new SHA:

PR #1 (A) PR #2 (B) PR #3 (C) amend C up to date up to date up to date up to date updated updated edit B up to date up to date updated updated updated updated edit A updated updated updated updated updated updated rebase on a newer main updated updated updated updated updated updated PR #1 (A) PR #2 (B) PR #3 (C) amend C up to date up to date up to date up to date updated updated edit B up to date up to date updated updated updated updated edit A updated updated updated updated updated updated rebase on a newer main updated updated updated updated updated updated
A push updates the pull request of every commit whose SHA changed: the one you edited and every one above it, or all of them when the push rebases the stack onto a newer base. Editing a commit rewrites the commits on top of it. Orange is updated, grey is up to date.

To change a commit’s message without touching its contents:

Terminal windowbash
mergify stack reword d4e5f6a -m "feat: add user registration API endpoint"

The Change-Id is preserved, so the PR keeps its identity. Because Stacks derives the PR title and body from the commit message, the corresponding PR’s title and body update on the next push.

List every commit in the order you want, by SHA or Change-Id prefix:

Terminal windowbash
mergify stack reorder d4e5f6a a1b2c3d b7c8d9e

To move a single commit without listing the whole stack, use move with first, last, before, or after:

Terminal windowbash
mergify stack move b7c8d9e first
mergify stack move a1b2c3d after d4e5f6a

The PRs re-chain automatically when you push.

Just commit normally anywhere in your branch:

Terminal windowbash
git add src/api/auth.py
git commit -m "feat: add authentication middleware"

On the next mergify stack push, a new PR is created and inserted at the correct position in the chain.

Drop one or more commits by SHA or Change-Id prefix:

Terminal windowbash
mergify stack drop d4e5f6a

On push, the orphan remote branch is deleted and the remaining PRs re-chain.

To fold a commit into its parent and drop its message, use fixup:

Terminal windowbash
mergify stack fixup b7c8d9e

To combine commits into a target while keeping the target’s message, use squash. Sources go before the into token, the target after it:

Terminal windowbash
mergify stack squash d4e5f6a into a1b2c3d

Pass -m to rewrite the resulting message instead of keeping the target’s:

Terminal windowbash
mergify stack squash d4e5f6a into a1b2c3d -m "feat: add user model and endpoint"

The surviving commit keeps its Change-Id, so the corresponding PR is updated. The absorbed commit’s remote branch is cleaned up automatically.

The history-rewriting commands (reword, reorder, move, drop, fixup, squash) accept --dry-run (-n) to print the resulting plan without changing your branch:

Terminal windowbash
mergify stack reorder d4e5f6a a1b2c3d b7c8d9e --dry-run

When you amend a commit that already has a PR, reviewers see a new revision but not the reason behind it. Attach a note before pushing to explain the change:

Terminal windowbash
git commit --amend
mergify stack note -m "address review: rename foo() to bar()"
mergify stack push

The note travels with the stack and appears in the PR’s revision history, so reviewers understand what changed between revisions without diffing SHAs. See Reviewing Stacks for the reviewer’s view.

By default, mergify stack push keeps a revision-history comment on each PR up to date. Pass --no-revision-history (or set mergify-cli.stack-revision-history to false) to turn it off.

When the bottom PR in your stack merges into main, bring your local branch back in sync:

Terminal windowbash
mergify stack sync

sync fetches the latest main, detects which commits already merged, drops them from your branch, and rebases the rest. Then push to update the remaining PRs:

Terminal windowbash
mergify stack push

Before the merge, your stack looks like this:

main A B C PR #1 base: main PR #2 base: PR #1 PR #3 base: PR #2 main A B C PR #1 base: main PR #2 base: PR #1 PR #3 base: PR #2

After PR #1 merges, commit A lands on main. The remaining PRs re-chain:

main B C PR #2 base: main PR #3 base: PR #2 main B C PR #2 base: main PR #3 base: PR #2

sync rebases on main, detects that the merged commit is already there, and skips it. The remaining PRs update as needed on the next push.

Keys on this page

  • pull_request_rules[].actions.dismiss_reviews {approved, changes_requested, message, when} or null · default not set

Was this page helpful?