Remotes, Pull Requests & GitHub Flow
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:
- Branch off
main - Commit your work and push the branch
- Open a pull request
- Review + CI checks pass
- 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"]
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
- Clone a repo, create a branch, push it, and open a pull request.
- Explain what
git push -u origin <branch>sets up (the upstream tracking). - Pull the latest main and confirm your merged change is present.
- Describe what CI checks add to a pull request before merge.
Cheat Sheet▾
| Task | Command |
|---|---|
| Clone | git clone <url> |
| Add remote | git remote add origin <url> |
| Push new branch | git push -u origin <branch> |
| Push updates | git push |
| Get updates | git pull |
| List remotes | git 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