[llvm] [Docs][Github] explain how to rectify gh pr merge failure (PR #66223)

Nick Desaulniers via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 13 08:55:44 PDT 2023


https://github.com/nickdesaulniers created https://github.com/llvm/llvm-project/pull/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.


>From a559dd6a64ff8a40d2252944e5eadae237d81c3e Mon Sep 17 00:00:00 2001
From: Nick Desaulniers <ndesaulniers at google.com>
Date: Wed, 13 Sep 2023 08:53:57 -0700
Subject: [PATCH] [Docs][Github] explain how to rectify gh pr merge failure

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.
---
 llvm/docs/GitHub.rst | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/llvm/docs/GitHub.rst b/llvm/docs/GitHub.rst
index d726c76e7d5f2d4..7b548056deccf5a 100644
--- a/llvm/docs/GitHub.rst
+++ b/llvm/docs/GitHub.rst
@@ -131,6 +131,33 @@ You can also merge via the CLI by switching to your branch locally and run:
 
   gh pr merge --squash --delete-branch
 
+If you observe an error message from the above informing you that your pull
+request is not mergeable, then that is likely because upstream has been
+modified since your pull request was authored in a way that now results in a
+merge conflict. You must first resolve this merge conflict in order to merge
+your pull request. In order to do that:
+
+::
+
+  git fetch origin
+  git rebase origin/main
+
+Then fix the source files causing merge conflicts.
+
+::
+
+  git add <files with resolved merge conflicts>
+  <rebuild + retest>
+  git rebase --continue
+
+Finally, you'll need to force push to your branch one more time before you can
+merge:
+
+::
+
+  git push -f
+  gh pr merge --squash --delete branch
+
 
 Checking out another PR locally
 -------------------------------



More information about the llvm-commits mailing list