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.
Amend the Latest Commit
Section titled Amend the Latest CommitMake your changes, then amend:
git add src/api/users.pygit commit --amendThe Change-Id is preserved automatically. Then push:
mergify stack pushOnly the PR corresponding to the amended commit is updated.
Edit a Commit Mid-Stack
Section titled Edit a Commit Mid-StackTo modify a commit that isn’t at the top of your branch, use interactive rebase. Stacks provides a shortcut:
mergify stack editThis opens git rebase -i from the fork point of your stack. You’ll see your
commits listed:
pick a1b2c3d feat: add user data modelpick d4e5f6a feat: add user registration endpointpick g7h8i9b test: add user registration testsChange pick to edit for the commit you want to modify:
edit a1b2c3d feat: add user data modelpick d4e5f6a feat: add user registration endpointpick g7h8i9b test: add user registration testsSave and close. Git pauses at that commit so you can make changes:
# Make your changesgit add src/models/user.pygit commit --amendgit rebase --continueThen push:
mergify stack pushReorder Commits
Section titled Reorder CommitsOpen interactive rebase and change the line order:
mergify stack editpick d4e5f6a feat: add user registration endpointpick a1b2c3d feat: add user data modelpick g7h8i9b test: add user registration testsSave and close. The PRs re-chain automatically when you push.
Add a Commit
Section titled Add a CommitJust commit normally anywhere in your branch:
git add src/api/auth.pygit 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.
Remove a Commit
Section titled Remove a CommitOpen interactive rebase and change pick to drop (or delete the line):
mergify stack editpick a1b2c3d feat: add user data modeldrop d4e5f6a feat: add user registration endpointpick g7h8i9b test: add user registration testsOn push, the orphan remote branch is deleted and the remaining PRs re-chain.
Squash Commits
Section titled Squash CommitsTo combine two commits into one, use squash or fixup in interactive rebase:
mergify stack editpick a1b2c3d feat: add user data modelsquash d4e5f6a feat: add user registration endpointpick g7h8i9b test: add user registration testsThe surviving commit keeps its Change-Id, so the corresponding PR is updated. The absorbed commit’s remote branch is cleaned up automatically.
After a PR Merges
Section titled After a PR MergesWhen 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:
mergify stack pushBefore the merge, your stack looks like this:
After PR #1 merges, commit A lands on main. The remaining PRs re-chain:
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?
Thanks for your feedback!