[llvm] [llvm][docs] Clean up the "Landing Your Change" section of the GitHub docs (PR #112869)
David Spickett via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 21 05:15:03 PDT 2024
================
@@ -135,62 +135,73 @@ you won't encounter merge conflicts when landing the PR.
Landing your change
-------------------
-When your PR has been accepted you can use the web interface to land your change.
-If you have created multiple commits to address feedback at this point you need
-to consolidate those commits into one commit. There are two different ways to
-do this:
-`Interactive rebase <https://git-scm.com/docs/git-rebase#_interactive_mode>`_
-with fixup's. This is the recommended method since you can control the final
-commit message and inspect that the final commit looks as you expect. When
-your local state is correct, remember to force-push to your branch and press
-the merge button afterwards.
+When your PR has been accepted you can merge your changes.
-Use the button `Squash and merge` in GitHub's web interface, if you do this
-remember to review the commit message when prompted.
+If you do not have write permissions for the repository, the merge button in
+GitHub's web interface will be disabled. If this is the case, continue following
+the steps here but ask one of your reviewers to click the merge button on your
+behalf.
-Afterwards you can select the option `Delete branch` to delete the branch
-from your fork.
+If the PR is a single commit, all you need to do is click the merge button in
+GitHub's web interface.
-You can also merge via the CLI by switching to your branch locally and run:
+If your PR contains multiple commits, you need to consolidate those commits into
+one commit. There are three different ways to do this, shown here with the most
+commonly used first:
-::
+* Use the button `Squash and merge` in GitHub's web interface, if you do this
+ remember to review the commit message when prompted.
- gh pr merge --squash --delete-branch
+ Afterwards you can select the option `Delete branch` to delete the branch
+ from your fork.
-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:
+* `Interactive rebase <https://git-scm.com/docs/git-rebase#_interactive_mode>`_
+ with fixups. This is the recommended method since you can control the final
+ commit message and check that the final commit looks as you expect. When
+ your local state is correct, remember to force-push to your branch and press
+ the merge button in GitHub's web interface afterwards.
-::
+* Merge using the GitHub command line interface. Switch to your branch locally
+ and run:
- git fetch upstream
- git rebase upstream/main
+ ::
-Then fix the source files causing merge conflicts and make sure to rebuild and
-retest the result. Then:
+ 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 add <files with resolved merge conflicts>
- git rebase --continue
+ ::
-Finally, you'll need to force push to your branch one more time before you can
-merge:
+ git fetch upstream
+ git rebase upstream/main
-::
+ Then fix the source files causing merge conflicts and make sure to rebuild and
+ retest the result. Then:
- git push -f
- gh pr merge --squash --delete-branch
+ ::
+
+ git add <files with resolved merge conflicts>
+ 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
-This force push may ask if you intend to push hundreds, or potentially
-thousands of patches (depending on how long it's been since your pull request
-was initially authored vs. when you intended to merge it). Since you're pushing
-to a branch in your fork, this is ok and expected. Github's UI for the pull
-request will understand that you're rebasing just your patches, and display
-this result correctly with a note that a force push did occur.
+ This force push may ask if you intend to push hundreds, or potentially
+ thousands of patches (depending on how long it's been since your pull request
+ was initially authored vs. when you intended to merge it). Since you're pushing
+ to a branch in your fork, this is ok and expected. Github's UI for the pull
+ request will understand that you're rebasing just your patches, and display
+ this result correctly with a note that a force push did occur.
----------------
DavidSpickett wrote:
This option is new to me, so I might be misunderstanding it.
In this context the branch you're rebasing onto is the upstream `main` so yes that has a lot of other authors. If you're the only author of the branch being rebased then there shouldn't be a problem. Unless you forgot that you had pushed a more recent version of the branch from a different machine (which I've done but luckily I had access to both so I could recover it).
If there were multiple authors on a single branch for a single PR, then you don't want to overwrite their changes.
If you have squashed your changes locally, you will want to replace them in the remote branch. So `--force` is what you'd want to use.
So a note recommending `--force-with-lease` for branches with multiple authors seems appropriate, what do you think?
(and I will expand `-f` in the existing example to `--force` for clarity)
https://github.com/llvm/llvm-project/pull/112869
More information about the llvm-commits
mailing list