Remotes, Pull Requests & GitHub Flow

💤0
Lv 10 XP
← 🧱 Foundations · Git & GitHub

Remotes, Pull Requests & GitHub Flow

Beginner ⭐ 50 XP ⏱ 18 min #git#github#pull-requests

Collaborate using remotes, pull requests, and the lightweight GitHub Flow.

📖Theory

A remote is a shared copy of the repository, conventionally named origin. You push local commits to it and pull others’ commits down. Hosting platforms like GitHub add pull requests (PRs) — a place to propose, review, and discuss a branch before it merges.

GitHub Flow is the simple, popular workflow:

  1. Branch off main
  2. Commit your work and push the branch
  3. Open a pull request
  4. Review + CI checks pass
  5. Merge to main (which is always deployable) and delete the branch

This keeps main healthy and makes every change reviewable and traceable.

graph LR
  A["Branch off main"] --> B["Commit + push"]
  B --> C["Open PR"]
  C --> D["Review + CI"]
  D --> E["Merge to main"]
  E --> F["Delete branch"]
GitHub Flow
🌍Real-World Example
git clone https://github.com/you/repo.git
git switch -c feature/x
# ...commit work...
git push -u origin feature/x      # publish the branch
# open a PR on GitHub, get review, merge

git switch main
git pull                          # get the merged changes
✍️Hands-On Exercise
  1. Clone a repo, create a branch, push it, and open a pull request.
  2. Explain what git push -u origin <branch> sets up (the upstream tracking).
  3. Pull the latest main and confirm your merged change is present.
  4. Describe what CI checks add to a pull request before merge.
🧾Cheat Sheet
TaskCommand
Clonegit clone <url>
Add remotegit remote add origin <url>
Push new branchgit push -u origin <branch>
Push updatesgit push
Get updatesgit pull
List remotesgit remote -v
💬Common Interview Questions
What is a pull request?

A proposal to merge one branch into another, hosted on a platform like GitHub, that enables code review, discussion, and automated checks before the merge.

Describe GitHub Flow.

Branch off main, commit and push, open a PR, pass review and CI, then merge to main (kept always-deployable) and delete the branch.

📚Official Documentation

📝 My notes on this topic

Auto-saves as you type