Remotes
Every clone is complete; push and pull keep them in step
Commit is local. Push sends, pull receives.
Git was built so that everyone has the whole history. GitHub is where the copies meet. Cloning gives you a complete repository on your laptop, not a window onto a server. You commit there, with no network at all. So far nobody else can see it. Pushing sends your new commit to GitHub. And when a colleague pulls, the commit arrives in their copy too.
Remotes · Going deeper
Fetch, pull and origin/main
fetch downloads. pull downloads and merges.
Pushing
A push is refused if the remote has commits you lack
Pull first, then push. Force deletes other people's work.
Sooner or later, a push will be refused. While you were working on C, a colleague pushed E. The two copies have forked. You push, and GitHub says no: accepting your branch as it is would lose E. So you pull. Git fetches E and merges it with your C. Now your branch contains everything GitHub has, plus your work. The push goes through.
Pull requests
A pull request is a conversation that ends in a merge
Branch, push, open, checks, review, merge.
On a team, nobody commits straight to main. A change travels as a pull request. You make a branch for one change. You push it to GitHub. You open a pull request, asking for the branch to be merged into main, and say what it does and why. Automatic checks build and test it. A colleague reviews it. If they ask for changes, you push more commits to the same branch and the pull request updates. Once approved and green, it is merged.
Pull requests · Going deeper
Three ways to merge a pull request
Merge commit, squash or rebase: same content, different history.
Branch protection
Branch protection makes the platform enforce the rules
No direct pushes, no merging without approval and green checks.
A process that depends on everyone remembering it will fail on a busy day. So the rules are set on the branch itself. Someone tries to push directly to main. Blocked: changes must arrive through a pull request. A pull request is approved, but one of the required checks is failing. Blocked. A pull request with an approval and every check green. This one, and only this one, can be merged.
Repository roles · Going deeper · 1 of 2
Five roles decide who can read, triage, push, maintain and administer
Read, Triage, Write, Maintain, Admin: give the lowest role that does the job.
CODEOWNERS · Going deeper · 2 of 2
In CODEOWNERS the last matching line wins, not the most specific
Order CODEOWNERS from general to specific: the last match decides.
Issues
An issue says what and why; a pull request says how
Fixes #42 links the work to its reason, and closes the issue on merge.
Work starts before the code does. Someone opens an issue: what is wrong, and why it matters. A branch is made for it. The pull request says "fixes number forty two", which links the two. When it is merged, GitHub closes the issue by itself. The value shows years later. From any line of code you can walk back to its commit, the pull request that discussed it, and the issue that asked for it.
Issues · Going deeper
Forks: contributing without write access
Push to your fork, then open a pull request to upstream.
Lesson complete
You finished “Working together on GitHub”
Nicely done.