[llvm] [Docs] Add example of making a PR with git and GitHub web interface (PR #65393)
Michael Maitland via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 7 06:58:10 PDT 2023
https://github.com/michaelmaitland updated https://github.com/llvm/llvm-project/pull/65393:
>From 9dc65746fb8afbfe067c5b15ba76e24588fcbfc2 Mon Sep 17 00:00:00 2001
From: Michael Maitland <michaeltmaitland at gmail.com>
Date: Tue, 5 Sep 2023 10:33:24 -0700
Subject: [PATCH 1/7] [Docs] Add example of making a PR with git and GitHub web
interface
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.
---
llvm/docs/GitHub.rst | 70 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 70 insertions(+)
diff --git a/llvm/docs/GitHub.rst b/llvm/docs/GitHub.rst
index 48ddfe515a2ee84..5429aa22393748b 100644
--- a/llvm/docs/GitHub.rst
+++ b/llvm/docs/GitHub.rst
@@ -207,6 +207,76 @@ 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 and create a new branch
+ cd llvm-project
+ 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
+
+Now back on the GitHub web interface, navigate to your fork and 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"
+
+ # 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
+
+ # When your PR is accepted, you can now rebase it and make sure
+ # you have all the latest changes.
+ git rebase -i origin/main
+
+ # If this PR is older and you get a lot of new commits with the
+ # rebase, you might want to re-run tests and make sure nothing
+ # broke.
+ ninja check-llvm
+
+Once your PR is approved, rebased, and tests are passing, click `Squash and
+Merge` on your PR in the GitHub web interface.
+
Releases
========
>From d3de3c753feebb5d1ee6b76a95633814b703313c Mon Sep 17 00:00:00 2001
From: Michael Maitland <michaeltmaitland at gmail.com>
Date: Tue, 5 Sep 2023 12:39:04 -0700
Subject: [PATCH 2/7] fixup! [Docs] Add example of making a PR with git and
GitHub web interface
---
llvm/docs/GitHub.rst | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/llvm/docs/GitHub.rst b/llvm/docs/GitHub.rst
index 5429aa22393748b..08a66c91a02362d 100644
--- a/llvm/docs/GitHub.rst
+++ b/llvm/docs/GitHub.rst
@@ -246,8 +246,8 @@ Once you've cloned your forked repository,
# fork and upstream to llvm/llvm-project
git push origin my_change
-Now back on the GitHub web interface, navigate to your fork and create a pull
-request from your branch to llvm::main.
+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.
::
@@ -259,6 +259,12 @@ request from your branch to llvm::main.
# 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
+
# 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
>From 2adc8d05900927d25204c05c1912b0785e30de96 Mon Sep 17 00:00:00 2001
From: Michael Maitland <michaeltmaitland at gmail.com>
Date: Tue, 5 Sep 2023 14:31:28 -0700
Subject: [PATCH 3/7] fixup! [Docs] Add example of making a PR with git and
GitHub web interface
---
llvm/docs/GitHub.rst | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/llvm/docs/GitHub.rst b/llvm/docs/GitHub.rst
index 08a66c91a02362d..0a0561a4a70184b 100644
--- a/llvm/docs/GitHub.rst
+++ b/llvm/docs/GitHub.rst
@@ -265,21 +265,29 @@ Create a pull request from your branch to llvm::main.
# Recommit if any formatting changes
git commit -a --amend
+ # Re-run tests and make sure nothing broke.
+ ninja check-llvm
+
# 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
- # When your PR is accepted, you can now rebase it and make sure
- # you have all the latest changes.
+Before merging the PR, it is reccomended that you rebase locally and re-run test
+checks:
+
+::
+
+ # Make sure you have all the latest changes
git rebase -i origin/main
- # If this PR is older and you get a lot of new commits with the
- # rebase, you might want to re-run tests and make sure nothing
- # broke.
+ # Make sure tests pass with latest changes and your change
ninja check-llvm
+ # Push the rebased changes to your fork.
+ git push origin my_change
+
Once your PR is approved, rebased, and tests are passing, click `Squash and
Merge` on your PR in the GitHub web interface.
>From a15b55b4afc67c51fcbab8089a830d94126b07c3 Mon Sep 17 00:00:00 2001
From: Michael Maitland <michaeltmaitland at gmail.com>
Date: Tue, 5 Sep 2023 14:39:13 -0700
Subject: [PATCH 4/7] fixup! [Docs] Add example of making a PR with git and
GitHub web interface
---
llvm/docs/GitHub.rst | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/llvm/docs/GitHub.rst b/llvm/docs/GitHub.rst
index 0a0561a4a70184b..0ce18486a90c8da 100644
--- a/llvm/docs/GitHub.rst
+++ b/llvm/docs/GitHub.rst
@@ -224,8 +224,13 @@ Once you've cloned your forked repository,
::
- # Switch to the forked repo and create a new branch
+ # Switch to the forked repo
cd llvm-project
+
+ # Add upstream as a remote
+ git remote add upstream https://github.com/llvm/llvm-project.git
+
+ # Create a new branch
git switch -c my_change
# Create your changes
@@ -274,16 +279,16 @@ Create a pull request from your branch to llvm::main.
# fork and upstream to llvm/llvm-project
git push origin my_change
-Before merging the PR, it is reccomended that you rebase locally and re-run test
+Before merging the PR, it is recommended that you rebase locally and re-run test
checks:
::
# Make sure you have all the latest changes
- git rebase -i origin/main
+ git fetch upstream && git rebase -i upstream/main
# Make sure tests pass with latest changes and your change
- ninja check-llvm
+ ninja check
# Push the rebased changes to your fork.
git push origin my_change
>From 5dd76774a20a5d3a0e97494725f5761741c1b9d3 Mon Sep 17 00:00:00 2001
From: Michael Maitland <michaeltmaitland at gmail.com>
Date: Wed, 6 Sep 2023 09:26:11 -0700
Subject: [PATCH 5/7] fixup! [Docs] Add example of making a PR with git and
GitHub web interface
---
llvm/docs/GitHub.rst | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/llvm/docs/GitHub.rst b/llvm/docs/GitHub.rst
index 0ce18486a90c8da..b8b564fc25430a9 100644
--- a/llvm/docs/GitHub.rst
+++ b/llvm/docs/GitHub.rst
@@ -227,9 +227,6 @@ Once you've cloned your forked repository,
# Switch to the forked repo
cd llvm-project
- # Add upstream as a remote
- git remote add upstream https://github.com/llvm/llvm-project.git
-
# Create a new branch
git switch -c my_change
@@ -284,6 +281,9 @@ 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
>From ee85545fc7a9ec7030c198c4113ca3cc384e7b46 Mon Sep 17 00:00:00 2001
From: Michael Maitland <michaeltmaitland at gmail.com>
Date: Wed, 6 Sep 2023 09:27:34 -0700
Subject: [PATCH 6/7] fixup! [Docs] Add example of making a PR with git and
GitHub web interface
---
llvm/docs/GitHub.rst | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/docs/GitHub.rst b/llvm/docs/GitHub.rst
index b8b564fc25430a9..36ea2f91d07222b 100644
--- a/llvm/docs/GitHub.rst
+++ b/llvm/docs/GitHub.rst
@@ -268,7 +268,7 @@ Create a pull request from your branch to llvm::main.
git commit -a --amend
# Re-run tests and make sure nothing broke.
- ninja check-llvm
+ ninja check
# Push your changes to your fork branch, be mindful of
# your remotes here, if you don't remember what points to your
>From ad3a198d595c64842d2260122a7bc7006ecce1ad Mon Sep 17 00:00:00 2001
From: Michael Maitland <michaeltmaitland at gmail.com>
Date: Thu, 7 Sep 2023 06:57:48 -0700
Subject: [PATCH 7/7] fixup! [Docs] Add example of making a PR with git and
GitHub web interface
---
llvm/docs/GitHub.rst | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/docs/GitHub.rst b/llvm/docs/GitHub.rst
index 36ea2f91d07222b..7d45f3d42172755 100644
--- a/llvm/docs/GitHub.rst
+++ b/llvm/docs/GitHub.rst
@@ -291,7 +291,7 @@ checks:
ninja check
# Push the rebased changes to your fork.
- git push origin my_change
+ 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.
More information about the llvm-commits
mailing list