View as Markdown

Updating Stacks

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


After pushing a stack, you’ll need to make changes: responding to review feedback, adding commits, rearranging order, or squashing. This page covers every common scenario.

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

Make your changes, then amend:

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

The Change-Id is preserved automatically. Then push:

Terminal window
mergify stack push

Only the PR corresponding to the amended commit is updated.

To modify a commit that isn’t at the top of your branch, use interactive rebase. Stacks provides a shortcut:

Terminal window
mergify stack edit

This opens git rebase -i from the fork point of your stack. You’ll see your commits listed:

pick a1b2c3d feat: add user data model
pick d4e5f6a feat: add user registration endpoint
pick g7h8i9b test: add user registration tests

Change pick to edit for the commit you want to modify:

edit a1b2c3d feat: add user data model
pick d4e5f6a feat: add user registration endpoint
pick g7h8i9b test: add user registration tests

Save and close. Git pauses at that commit so you can make changes:

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

Then push:

Terminal window
mergify stack push

Open interactive rebase and change the line order:

Terminal window
mergify stack edit
pick d4e5f6a feat: add user registration endpoint
pick a1b2c3d feat: add user data model
pick g7h8i9b test: add user registration tests

Save and close. The PRs re-chain automatically when you push.

Just commit normally anywhere in your branch:

Terminal window
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.

Open interactive rebase and change pick to drop (or delete the line):

Terminal window
mergify stack edit
pick a1b2c3d feat: add user data model
drop d4e5f6a feat: add user registration endpoint
pick g7h8i9b test: add user registration tests

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

To combine two commits into one, use squash or fixup in interactive rebase:

Terminal window
mergify stack edit
pick a1b2c3d feat: add user data model
squash d4e5f6a feat: add user registration endpoint
pick g7h8i9b test: add user registration tests

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

When the bottom PR in your stack merges into main, the next PR’s base automatically updates to main. To keep your local branch in sync, just push again:

Terminal window
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

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

Stacks rebases on main automatically, detects that the merged commit is already in main, and skips it. The remaining PRs update as needed.

Was this page helpful?