Skip to content

Commit 102715a

Browse files
[Docs][Github] explain how to rectify gh pr merge failure (#66223)
I recently went to merge a PR that had a merge conflict: $ gh pr merge --squash --delete-branch X Pull request #66003 is not mergeable: the merge commit cannot be cleanly created. To have the pull request merged after all the requirements have been met, add the `--auto` flag. Run the following to resolve the merge conflicts locally: gh pr checkout 66003 && git fetch origin main && git merge origin/main This is how I resolved it; we should recommend this explicitly for fellow contributors.
1 parent 2793ef6 commit 102715a

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

llvm/docs/GitHub.rst

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,45 @@ You can also merge via the CLI by switching to your branch locally and run:
131131

132132
gh pr merge --squash --delete-branch
133133

134+
If you observe an error message from the above informing you that your pull
135+
request is not mergeable, then that is likely because upstream has been
136+
modified since your pull request was authored in a way that now results in a
137+
merge conflict. You must first resolve this merge conflict in order to merge
138+
your pull request. In order to do that:
139+
140+
::
141+
142+
git fetch upstream
143+
git rebase upstream/main
144+
145+
Then fix the source files causing merge conflicts and make sure to rebuild and
146+
retest the result. Then:
147+
148+
::
149+
150+
git add <files with resolved merge conflicts>
151+
git rebase --continue
152+
153+
Finally, you'll need to force push to your branch one more time before you can
154+
merge:
155+
156+
::
157+
158+
git push -f
159+
gh pr merge --squash --delete branch
160+
161+
This force push may ask if you intend to push hundreds, or potentially
162+
thousands of patches (depending on how long it's been since your pull request
163+
was initially authored vs. when you intended to merge it). Since you're pushing
164+
to a branch in your fork, this is ok and expected. Github's UI for the pull
165+
request will understand that you're rebasing just your patches, and display
166+
this result correctly with a note that a force push did occur.
167+
134168

135169
Checking out another PR locally
136170
-------------------------------
137171
Sometimes you want to review another person's PR on your local machine to run
138-
tests or inspect code in your prefered editor. This is easily done with the
172+
tests or inspect code in your preferred editor. This is easily done with the
139173
CLI:
140174

141175
::

0 commit comments

Comments
 (0)