Learn how to seamlessly merge a single PR or stack of PRs with Graphite and handle merge conflicts efficiently.
Merge
button will just merge that single PR.
Merge N
where N
is your position in the stack and will merge all PRs up until the N
th.
Merge (N) PRs
lets you fire-and-forget merging your stack. When you click the button, Graphite automatically merges each of your PRs one-by-one.
This feature rebases PRs on an as-needed basis (to avoid merge conflicts generated by GitHub’s lack of stack support). And it waits for GitHub checks to pass at each step of the way before merging.
Merge all (n)
on PR 3 to merge those into trunk—just make sure you gt sync
and gt submit
the rest of your stack before merging again.merge
will first present you with a modal to configure your merge options before starting the merge job. In this merge modal, you have the option to:
gt sync
on the Graphite CLI immediately after merging a change to your remote trunk branch—this will zip through and delete your merged branches, ensuring that your local environment is up-to-date and ready for you to keep developing.Merge (N)
fails due to a rebase conflict, go to your terminal and run gt sync
&& gt restack
&& gt submit --stack
(resolving any conflicts along the way and running gt continue
). Once you’ve done this, go back to the affected PR in Graphite (or to the same place in the stack where you initially kicked off the Merge (N)
job), and click Merge (N)
one more time to re-queue the PR for merging.
PR A
at the base, followed by PR B
and PR C
, when PR A
is merged into trunk:
PR A
.
PR B
and trunk does not change.
PR B
now includes the commits of both PR B
and the already-merged commits of PR A
.
PR A
and PR B
that modify the same lines and you merge both PRs using one of the aforementioned merge strategies. For any PR C
that is stacked atop PR A
and B
, the following transpires:
PR B
.
PR C
contains the commits in PR A
and PR B
.
PR C
, it first tries to apply PR A
—and now gets a merge conflict—even though in reality you’re simply replaying history and there’s no new change.
gt sync
will pull down the latest changes and rebase PR C for you, cutting out the problematic commits—and a subsequent re-submit will then eliminate the detected merge conflict for PR C.
Merge (N)
is designed to similarly automatically resolve this type of merge conflict without the need for manual intervention or monitoring. When a merge conflict is found, the merge cron performs a shallow clone of the repository, containing just the stack commits and the trunk commit and utilizes Graphite’s knowledge of the stack to perform the same set of operations.
m
merge conflicts, there will only be m
total rebases (and additional CI runs) kicked off by the merge process.
Merge (N)
will take n
minutes, but if there are merge conflicts, job time is a byproduct of the time it takes to run GitHub checks on a PR and how many PRs encounter merge conflicts.
Merge (N)
will work with your team’s merge process, feel free to reach out to support@graphite.dev—we’d love to help you with this.
graphite-base/*
branches that you can ignoremerge
from the Graphite app. This feature does not work when merging from GitHub.
graphite-base/*
branches that lets Graphite retarget the rebased branches atomically — ensuring your CODEOWNERS rules and GitHub Actions workflows don’t misfire.
graphite-base/*
. Not doing so can result in unnecessary builds for these temporary branches and cancelled jobs when Graphite deletes these branches.
Here’s how to disable running CI for these branches in GitHub Actions: