Remotes and GitHub
Forks and pull requests
Use a fork to propose work across repository boundaries and a pull request to review a branch before merging.
8 minute lesson
A fork is a repository hosted under another GitHub account. It gives you a place to push branches when you cannot or should not push to the original repository.
Your local clone can keep both repositories as remotes:
git remote -v
A common convention is origin for your fork and upstream for the original repository. These names are conventions, so inspect the URLs instead of assuming.
A pull request asks maintainers to review and merge one branch into another. It is a GitHub collaboration feature, not a core Git command.
Before opening one, fetch the target repository, inspect the graph, and make sure your branch contains only the intended commits:
git fetch upstream
git log --oneline upstream/main..HEAD
git diff upstream/main...HEAD
The commit range shows work reachable from your branch but not from upstream/main. The three-dot diff compares your branch with their merge base.
Keep the pull request focused and explain what changed, why, and how you tested it.
Review comments may lead to more commits on the same branch. The pull request updates when you push them.
Exercise: inspect a branch against its intended base. Can every listed commit and changed file be explained by one purpose?
Lesson completed