[llvm] 93cc72b - [Docs] Add example of making a PR with git and GitHub web interface (#65393)

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 7 06:58:48 PDT 2023


Author: Michael Maitland
Date: 2023-09-07T09:58:43-04:00
New Revision: 93cc72be993f01cc6121aa6b04ea7d3450c37ff3

URL: https://github.com/llvm/llvm-project/commit/93cc72be993f01cc6121aa6b04ea7d3450c37ff3
DIFF: https://github.com/llvm/llvm-project/commit/93cc72be993f01cc6121aa6b04ea7d3450c37ff3.diff

LOG: [Docs] Add example of making a PR with git and GitHub web interface (#65393)

Some people may not have access to `gh` or may prefer to use `git` and
the GitHub web interface to make a PR. This patch adds an example of
making a PR using this approach.

Added: 
    

Modified: 
    llvm/docs/GitHub.rst

Removed: 
    


################################################################################
diff  --git a/llvm/docs/GitHub.rst b/llvm/docs/GitHub.rst
index 48ddfe515a2ee84..7d45f3d42172755 100644
--- a/llvm/docs/GitHub.rst
+++ b/llvm/docs/GitHub.rst
@@ -207,6 +207,95 @@ See more in-depth information about how to contribute in the following documenta
 * :doc:`Contributing`
 * :doc:`MyFirstTypoFix`
 
+Example Pull Request with git
+====================================
+
+Instead of using the GitHub CLI to create a PR, you can push your code to a
+remote branch on your fork and create the PR to upstream using the GitHub web
+interface.
+
+Here is an example of making a PR using git and the GitHub web interface:
+
+First follow the instructions to [fork the repository](https://docs.github.com/en/get-started/quickstart/fork-a-repo?tool=webui#forking-a-repository).
+
+Next follow the instructions to [clone your forked repository](https://docs.github.com/en/get-started/quickstart/fork-a-repo?tool=webui#cloning-your-forked-repository).
+
+Once you've cloned your forked repository,
+
+::
+
+  # Switch to the forked repo
+  cd llvm-project
+
+  # Create a new branch
+  git switch -c my_change
+
+  # Create your changes
+  $EDITOR file.cpp
+
+  # Don't forget clang-format
+  git clang-format
+
+  # and don't forget running your tests
+  ninja check-llvm
+
+  # Commit, use a good commit message
+  git commit file.cpp
+
+  # Push your changes to your fork branch, be mindful of
+  # your remotes here, if you don't remember what points to your
+  # fork, use git remote -v to see. Usually origin points to your
+  # fork and upstream to llvm/llvm-project
+  git push origin my_change
+
+Navigate to the URL printed to the console from the git push command in the last step.
+Create a pull request from your branch to llvm::main.
+
+::
+
+  # If you get any review comments, come back to the branch and
+  # adjust them.
+  git switch my_change
+  $EDITOR file.cpp
+
+  # Commit your changes
+  git commit file.cpp -m "Code Review adjustments"
+
+  # Format changes
+  git clang-format HEAD~
+
+  # Recommit if any formatting changes
+  git commit -a --amend
+
+  # Re-run tests and make sure nothing broke.
+  ninja check
+
+  # Push your changes to your fork branch, be mindful of
+  # your remotes here, if you don't remember what points to your
+  # fork, use git remote -v to see. Usually origin points to your
+  # fork and upstream to llvm/llvm-project
+  git push origin my_change
+
+Before merging the PR, it is recommended that you rebase locally and re-run test
+checks:
+
+::
+
+  # Add upstream as a remote
+  git remote add upstream https://github.com/llvm/llvm-project.git
+
+  # Make sure you have all the latest changes
+  git fetch upstream && git rebase -i upstream/main
+
+  # Make sure tests pass with latest changes and your change
+  ninja check
+
+  # Push the rebased changes to your fork.
+  git push origin my_change -f
+
+Once your PR is approved, rebased, and tests are passing, click `Squash and
+Merge` on your PR in the GitHub web interface.
+
 Releases
 ========
 


        


More information about the llvm-commits mailing list