TExcelTAD
Home › Git › GitHub Pull Request

GitHub Pull Request

A pull request (PR; "merge request" on GitLab) asks the owners of a repository to merge a branch. It is not a Git command but a page on the hosting service that bundles the branch's commits, the diff, a description, review comments and test results, plus a Merge button.

The contributor's side

  1. Fork the project and clone your fork (previous lessons).
  2. Create a branch for the change: git switch -c fix/timer-units.
  3. Commit, then push the branch to your fork: git push -u origin fix/timer-units.
  4. On GitHub, click Compare & pull request. The base is tealab/kettle:main, the head is ada/kettle:fix/timer-units.
  5. Write a title and description: what changed, why, how you tested it, and link the issue ("Fixes #12" closes it on merge).
bash · try it yourself
git init -q --bare ~/github/tealab/kettle.git
git clone -q ~/github/tealab/kettle.git ~/maintainer 2>/dev/null && cd ~/maintainer
printf 'green=120\nblack=240\n' > times.cfg && git add . && git commit -q -m "Add brewing times" && git push -q
git clone -q --bare ~/github/tealab/kettle.git ~/github/ada/kettle.git

# contributor
git clone -q ~/github/ada/kettle.git ~/kettle && cd ~/kettle
git switch -c fix/timer-units
printf '# brewing times in seconds\ngreen=120\nblack=240\n' > times.cfg
git commit -q -am "Document that brewing times are in seconds"
git push -u origin fix/timer-units
Switched to a new branch 'fix/timer-units'
To /home/learner/github/ada/kettle.git
 * [new branch]      fix/timer-units -> fix/timer-units
branch 'fix/timer-units' set up to track 'origin/fix/timer-units'.

Git also has a built-in way to describe a branch for someone else to pull, git request-pull. It prints the text that GitHub's PR page presents graphically:

bash · try it yourself
git init -q --bare ~/github/tealab/kettle.git
git clone -q ~/github/tealab/kettle.git ~/maintainer 2>/dev/null && cd ~/maintainer
printf 'green=120\nblack=240\n' > times.cfg && git add . && git commit -q -m "Add brewing times" && git push -q
git clone -q --bare ~/github/tealab/kettle.git ~/github/ada/kettle.git
git clone -q ~/github/ada/kettle.git ~/kettle && cd ~/kettle
git switch -q -c fix/timer-units
printf '# brewing times in seconds\ngreen=120\nblack=240\n' > times.cfg
git commit -q -am "Document that brewing times are in seconds"
git push -q -u origin fix/timer-units

git request-pull origin/main ~/github/ada/kettle.git fix/timer-units
The following changes since commit b94c38932546661ee26a47539c271b32677324ca:

  Add brewing times (2026-01-15 10:00:00 +0000)

are available in the Git repository at:

  /home/learner/github/ada/kettle.git fix/timer-units

for you to fetch changes up to 34efd9ba1a11e6bf163fc9f13e18a3c0c8b2c284:

  Document that brewing times are in seconds (2026-01-15 10:00:00 +0000)

----------------------------------------------------------------
Ada Lovelace (1):
      Document that brewing times are in seconds

 times.cfg | 1 +
 1 file changed, 1 insertion(+)

The maintainer's side

A reviewer reads the diff, leaves comments and either approves or requests changes. To test a PR locally, the maintainer fetches the contributor's branch. The three-dot diff main...branch shows only what the branch changed since it split from main, exactly the "Files changed" tab:

bash · try it yourself
git init -q --bare ~/github/tealab/kettle.git
git clone -q ~/github/tealab/kettle.git ~/maintainer 2>/dev/null && cd ~/maintainer
printf 'green=120\nblack=240\n' > times.cfg && git add . && git commit -q -m "Add brewing times" && git push -q
git clone -q --bare ~/github/tealab/kettle.git ~/github/ada/kettle.git
git clone -q ~/github/ada/kettle.git ~/kettle && cd ~/kettle
git switch -q -c fix/timer-units
printf '# brewing times in seconds\ngreen=120\nblack=240\n' > times.cfg
git commit -q -am "Document that brewing times are in seconds" && git push -q -u origin fix/timer-units

# maintainer reviews and merges
cd ~/maintainer
git fetch -q ~/github/ada/kettle.git fix/timer-units:pr-1
git log --oneline main..pr-1
git diff main...pr-1
git merge -q --no-ff pr-1 -m "Merge pull request #1 from ada/fix/timer-units"
git push -q
git log --oneline --graph
34efd9b Document that brewing times are in seconds
diff --git a/times.cfg b/times.cfg
index 954a2e9..b46ebdd 100644
--- a/times.cfg
+++ b/times.cfg
@@ -1,2 +1,3 @@
+# brewing times in seconds
 green=120
 black=240
*   73ad9a7 Merge pull request #1 from ada/fix/timer-units
|\
| * 34efd9b Document that brewing times are in seconds
|/
* b94c389 Add brewing times

git fetch <url> <remote-branch>:<local-branch> downloads a branch from any repository into a local branch, without adding a remote. (On GitHub, git fetch origin pull/1/head:pr-1 does the same for any PR.)

Updating a pull request

A PR tracks its branch. When the reviewer asks for changes, commit on the same branch and push; the PR updates automatically and the conversation continues. If you rebased to tidy up, push with --force-with-lease (only to your own PR branch).

Writing a good pull request

Do Avoid
One topic per PR mixing a bug fix, a refactor and a new feature
A description explaining why an empty description
Small diffs (a few hundred lines) 3000-line PRs nobody can review
Screenshots for UI changes "see code"
Respond to every review comment silently force-pushing over feedback

Test yourself

When contributing via a fork, where do you push your branch?

  1. Directly to the original project's main
  2. To your fork (origin), then open a PR against the original
  3. To upstream/main
  4. Nowhere, you email the files

What does git diff main...feature (three dots) show?

  1. Differences in both directions
  2. The changes made on feature since it branched off main
  3. Only the changes on main
  4. The commit messages

A reviewer requests changes on your PR. What is the normal way to update it?

  1. Open a new PR
  2. Commit and push to the same branch
  3. Push to main
  4. Close and re-fork