Photo by Eric Er on Unsplash

On this page

This chapter follows Advanced Git.

A pull request (GitHub) or merge request (GitLab) is a proposal: “merge these commits from my branch into yours.” Underneath, it is still Git objects and refs—plus permissions, discussion, and checks on the host.

Without GitHub: patches and request-pull

Open-source projects predating hosts often used email:

Terminal window
git format-patch main --stdout > series.patch
git send-email --to=list@example.org series.patch

On the maintainer side:

Terminal window
git am < series.patch

git request-pull generates a summary maintainer can use to pull your branch from your public repo URL:

Terminal window
git request-pull main https://example.com/you/project.git feature/login

These flows still work for air-gapped or self-hosted workflows. Code review happens on mailing lists or chat instead of inline threads.

Forks versus branches on one repo

Same repository, feature branch: teammates with write access push feature/x, open a PR into main. Common for small teams.

Fork: you clone yourname/project, push there, open a PR yourname:feature → org:main. Required for drive-by contributors without write access. Sync the fork by fetching upstream and merging or rebasing.

Terminal window
git remote add upstream https://github.com/org/project.git
git fetch upstream
git switch main
git merge upstream/main
git push origin main

Pull request lifecycle on GitHub

  1. Create a branch locally; commit; git push -u origin feature/x.
  2. Open a PR on GitHub (or gh pr create).
  3. CI runs (see GitHub Actions).
  4. Reviewers comment; you push fixes to the same branch—the PR updates.
  5. Maintainer merges when checks and approvals pass.
Terminal window
gh pr create --fill
gh pr checkout 42
gh pr review --approve
gh pr merge --squash

Merge button choices

GitHub offers three strategies—same concepts as Merging versus rebasing:

Option Effect
Create a merge commit Preserves branch topology with a merge node
Squash and merge One commit on the base branch
Rebase and merge Linear history on base; rebased commits

Team policy picks one default; protect main so only PR merges land.

Branch protection and CODEOWNERS

Branch protection rules can require:

  • Pull request before merge
  • Approving reviews
  • Passing status checks
  • Linear history (disallow merge commits)

CODEOWNERS (.github/CODEOWNERS) auto-requests review from paths’ owners:

.github/CODEOWNERS
* @org/core-team
/src/payments/ @org/payments

Protection applies on the server; local Git does not enforce it.

Draft pull requests and linked issues

Draft PRs signal work in progress—CI may still run, but reviewers know not to merge. Closing keywords in PR descriptions (Fixes #123) link issues and can auto-close on merge.

When to prefer plain Git merge locally

Not every team uses PR UI. Maintainers may git fetch a contributor branch and git merge locally after review—functionally a PR without the web thread. Document whichever workflow your org uses.

Next: Collaborating with Git.

Check your understanding

Question 1 of 7

0 of 7 checked

  1. 1. How does a maintainer apply emailed patches in the article?

Search articles

Type a word to search published articles.

Open the search page