Pull Requests and Collaboration

Harry · 14 Sep 2026 · 3 views
Advertisement
Advertisement

Why pull requests

Pushing straight to main is risky on a shared project. A pull request (PR) proposes changes on a branch and opens them for review and automated checks before they merge. It is where discussion, code review and CI happen.

The feature-branch workflow

  1. Create a branch: git switch -c feature/search
  2. Commit your work and push the branch: git push -u origin feature/search
  3. On GitHub, open a Pull Request from that branch into main.
  4. Teammates review, CI runs, you push fixes to the same branch (the PR updates automatically).
  5. When approved, click Merge; then delete the branch.

Forking for open source

You usually cannot push to someone else’s repository. Instead you fork it (make your own copy on GitHub), clone your fork, branch, push and open a PR back to the original project.

git clone https://github.com/you/their-repo.git
git remote add upstream https://github.com/original/their-repo.git

Keep your fork up to date

While your PR is open, the original project moves on. Sync by pulling from upstream:

git fetch upstream
git switch main
git merge upstream/main
git push origin main

Key points

  • A pull request proposes a branch’s changes for review before merging.
  • The standard flow is branch → push → open PR → review → merge → delete branch.
  • For projects you cannot push to, fork, then PR back to upstream.
  • Keep a fork current by merging upstream/main regularly.
Share this post:

Comments (0)

Please login or register to comment.