Setup
Install Mergify CLI and configure your repository for stacked PRs.
Prerequisites
Section titled Prerequisites-
Install the Mergify CLI, see the CLI installation guide for instructions.
-
GitHub authentication: Stacks needs access to create PRs. Either:
- Set the
GITHUB_TOKENenvironment variable, or - Install the GitHub CLI and run
gh auth login
- Set the
-
Enable “Automatically delete head branches” in your GitHub repository settings (Settings > General > Pull Requests). When a stacked PR merges, this cleans up its remote branch automatically so the next PR in the chain can rebase onto
maincleanly.
Initialize Your Repository
Section titled Initialize Your RepositoryRun the setup command in your Git repository:
mergify stack setupThis installs:
-
A
commit-msgGit hook that automatically generates a Change-Id for every new commit. The Change-Id is how Stacks tracks the relationship between your local commits and their GitHub pull requests. -
A
pre-pushhook that warns you if you accidentally usegit pushinstead ofmergify stack push. -
A Claude Code skill that teaches the AI coding agent how to work with Mergify Stacks, so it automatically uses
mergify stack pushinstead ofgit push.
Verify It Works
Section titled Verify It WorksCreate a test commit to confirm the hook is active:
echo "test" >> test.txtgit add test.txtgit commit -m "test: verify stack setup"Check the commit message:
git log -1You should see a Change-Id trailer at the bottom of the message:
test: verify stack setup
Change-Id: Ia1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2Clean up the test commit if you don’t need it:
git reset HEAD~1Configuration
Section titled ConfigurationThese optional Git config settings let you customize Stacks behavior:
| Setting | Default | Description |
|---|---|---|
mergify-cli.stack-branch-prefix | stack/{username} | Prefix for remote branch names |
mergify-cli.stack-create-as-draft | false | Create PRs as drafts by default |
mergify-cli.stack-keep-pr-title-body | false | Don’t overwrite PR title/body on updates |
Example:
git config mergify-cli.stack-create-as-draft trueNext Steps
Section titled Next StepsHead to Creating Stacks to push your first stack.
Was this page helpful?
Thanks for your feedback!