Webbo3 Level 2 · JavaScript Development · Day 10 of 20
Git, GitHub and Project 2: Solve a Problem
Five people, one codebase, nobody overwriting anybody. The workflow every team you will ever join already uses.
By the end of today you can
- Explain why teams work on branches, and never straight on main
- Use the everyday Git commands without looking them up
- Write commit messages that are useful when something breaks
- Open a pull request, and review somebody else's properly
- Resolve a merge conflict without panicking
- Split a problem into issues and ship it as a team of five
Until today your repository has had one branch and one person. Today it gets four more people, and every habit that was merely untidy becomes genuinely expensive.
Learn this properly now, on a small project, rather than in your first job on a big one. The terminal boxes today are real: every command was run, and what you see is what Git printed. The short codes like 8e8d24f are commit ids; yours will be different, because every commit gets its own.
1. Why Branches Exist
Definition
A branch is your own line of work inside the project. You make changes on it freely, and nobody else sees them until you ask for them to be merged into the shared branch. main is the shared branch that must always work.
Real-Life Example
Five people editing one printed report with one pen, passing it around. Somebody crosses out a paragraph another person still needed, and nobody can tell who changed what.
Branches give each person a photocopy to scribble on. When their part is finished and checked, it is carefully copied into the master report.
Types of Branch in a Team
Picture everyone with their own photocopy of the report. The master copy (main) is only ever changed by carefully copying in a finished, checked part.
2. The Commands You Will Use Every Day
Definition
Git records your project as a series of commits: saved snapshots, each with a message. You stage the changes you want in the next snapshot, commit them, and push them to GitHub so the team can see them.
Real-Life Example
Packing a parcel. You choose which items go in the box (git add), seal it with a label saying what is inside (git commit), and hand it to the courier (git push).
Types of Command
| Command | What it does |
|---|---|
git status | What have I changed? Run it constantly. |
git switch -c name | Make a new branch and move onto it |
git add file | Stage a change for the next commit |
git commit -m "message" | Save the staged changes as a snapshot |
git push -u origin name | Send a new branch to GitHub for the first time |
git pull | Fetch and bring in everyone else's merged work |
git merge name | Bring another branch's work into this one |
?? in the status line means Git has never seen that file before. After the commit, the log shows both snapshots, newest first.
checkout does two unrelated jobs, which is why it confuses beginners. switch changes branch and restore discards changes. You will still see checkout everywhere, so recognise it, but write the clear ones.
The Daily Routine
Picture packing a parcel: choose what goes in (add), seal it with a label (commit), hand it to the courier (push). Each morning, you also open the post from your teammates (merge development).
3. Commit Messages That Earn Their Place
Definition
A commit message says what a commit changed. You will read them when something breaks and you are hunting for the commit that caused it, so they must make sense without the code.
Real-Life Example
Labels on boxes in a store room. "Stuff" and "misc" force you to open every box. "Winter jackets, size M" tells you straight away whether this is the box you need.
| Instead of | Write |
|---|---|
| update | Add empty state to the student list |
| fix bug | Fix page not resetting to 1 when the search changes |
| final | Normalise API response before rendering |
| asdf | Remove unused sort helper |
| changes | Debounce the search input at 300ms |
Finish the sentence "If applied, this commit will...". Present tense, says what changed, and never mentions how long it took.
Picture the labelled boxes: every commit message is a label that lets a stranger find the right box without opening them all.
4. Pull Requests and Code Review
Definition
A pull request (PR) on GitHub says: here is my branch, here is what it does, please check it before it goes in. Code review is a teammate reading and running it first. It is the most effective way teams catch bugs before users do.
Real-Life Example
A newspaper article goes to an editor before it is printed. The writer explains what the piece is about; the editor reads it, asks questions, and only then does it go to print.
Reviewing Somebody Else's Pull Request
- Pull the branch and run it. A review that only reads the code misses anything that happens on screen.
- Ask questions rather than issuing orders. "What happens here if items is empty?" lands very differently from "this is wrong".
- Say what is good. A review that is only criticism makes people defensive and slower.
- Check what this course has taught: user text through textContent, response.ok checked, an empty state, and code the author can explain.
Approving to be polite is how broken code reaches main with two names on it. If you have not understood it, say "I have not been able to review this properly yet". That is a completely acceptable thing to say, in this course and in a job.
Picture the editor's desk: nothing goes to print until someone other than the writer has read it and understood it.
5. Merge Conflicts
Definition
A merge conflict happens when two branches changed the same lines. Git cannot know which version is right, so it stops and asks you. It is not an error, and you have not broken anything.
Real-Life Example
Two people updated the same line of the class timetable: one moved the Monday lesson to 9am, the other to 10am. The secretary cannot guess, so she puts both on the notice board and asks you to decide.
How to Resolve It
- Above
=======is what is already on your branch (Git calls it HEAD). Below it is what is coming in from the other branch. - Edit the file so it reads correctly: keep one version, keep the other, or write a line that satisfies both.
- Delete all three marker lines. A leftover <<<<<<< is a syntax error, and it is the most common way a conflict resolution goes wrong.
- Then git add the file and git commit.
Carrying on from the conflict above, with config.js still full of markers:
Merge development into your branch every morning. Conflicts grow with how long branches drift apart: merged daily, they are small and obvious; left alone for a week, they are frightening.
Picture the secretary pinning both timetable versions on the board with a note: "Decide, then remove this note." The conflict markers are that note, and the note must come down.
6. Project 2: The Brief
Students at Webbo3 cannot find good learning resources in one place. They are scattered across YouTube, blogs, documentation and WhatsApp messages, and nobody knows which are any good. Build something that fixes that.
That is the whole brief, and it names a problem rather than a product. What you build is your team's decision, and part of what is assessed. Two teams can reasonably build different things from this.
What It Must Include
- Data from at least one real API, fetched and rendered.
- Search, and at least one filter or category.
- All four states from Day 9: loading, error, empty and the list.
- Modules, not one file: at least an API layer, a render layer and the wiring (Day 6).
- Works at phone width.
- A README explaining the problem, the solution and how to run it.
How the Team Works
| Role | Owns | Still writes code |
|---|---|---|
| Product Lead | What you are building, and what is out of scope | Yes |
| API Lead | Fetching, normalising, error handling | Yes |
| UI Lead | Layout, states, responsiveness | Yes |
| QA Lead | Testing every branch before it merges, keeping a bug list | Yes |
| Docs Lead | README, the demo, the presentation | Yes |
A role is an extra responsibility, not a job instead of programming. The commit history is checked at assessment, and a team member with no commits fails the project, whatever their team says about them.
The Working Rhythm
- Break the build into GitHub Issues, one per piece of work, each small enough for one person in half a day.
- Assign each issue to a person. One issue, one branch, one pull request.
- Nobody pushes to main or development directly. Ever.
- Every pull request needs one review from somebody else before it merges.
- A five-minute stand-up each morning: what I did, what I am doing, what is blocking me.
The Marking Rubric
| Criterion | Marks | What is being judged |
|---|---|---|
| The problem | 15 | Did you understand it and scope it sensibly, or build the first thing you thought of |
| It works | 25 | Real API data, search, filter, all four states, on a phone |
| Code quality | 20 | Modules, naming, no dead code, no repeated blocks |
| Git and collaboration | 25 | Branches, real commit messages, pull requests, reviews with real comments, every member committing |
| Presentation | 15 | Five minutes: the problem, the demo, what broke and what you did about it |
Twenty-five of the hundred marks are for how you worked together, and the repository is the evidence. Five commits all pushed by one person an hour before the deadline is a story the graph tells clearly, and it is marked as what it is.
Do This Now
- Create the repository. Add a README and a .gitignore before anything else.
- Create development off main. Protect both branches on GitHub if your plan allows it.
- Open at least eight issues and assign every one of them.
- Everybody creates their branch and pushes one commit today, so you find out today rather than on Thursday that somebody's Git access does not work.
- Agree three things in writing in the README: what you are building, what is out of scope, and who reviews whose pull requests.
Checkpoint
Q1. Why does nobody push straight to main?
main must work and be deployable at all times. Anything pushed straight to it is unreviewed and untested, and when it breaks, it breaks for the whole team at once.
Q2. You get a merge conflict. Have you broken something?
No. Two branches changed the same lines and Git is asking which is right. Edit the file, delete all three marker lines, then add and commit.
Q3. What is wrong with approving a pull request you have not read?
It puts your name on code you have not checked and removes the only barrier between a bug and main. Saying you have not reviewed it yet is always the better answer.
Q4. Why merge development into your branch every morning?
Conflicts grow with drift. Daily merges produce small, obvious conflicts; a week apart produces a merge nobody wants to do.
Tick Before You Move On
- ☐ Repository, README and .gitignore exist before any code
- ☐ A development branch exists, and nobody is pushing to main
- ☐ My commit messages finish "If applied, this commit will..."
- ☐ I resolved a merge conflict and removed every marker
- ☐ Eight or more issues exist, all assigned
- ☐ Every one of the five of us has pushed at least one commit today
- ☐ Scope, out of scope and review pairs are written in the README
Quick Recap
A branch is your own line of work; main stays working at all times. status, switch, add, commit, push, pull and merge are the whole daily vocabulary. Commit messages finish "If applied, this commit will...". A pull request is where review happens, and review is where bugs are caught. A conflict is a question, not a failure: decide, delete the markers, commit. Everybody codes, and twenty-five marks are for how the repository reads.
Final Scenario
It is Wednesday. Musa's API client and Amaka's filters both changed the same config line, and her pull request shows a conflict.
Nobody panics. Amaka merges development into her branch, reads the two versions between the markers, agrees the right one with Musa in the pull request comments, writes it, deletes the markers, commits, and asks Tunde to review. By lunch it is in development, and main never broke.
That is what working in a team looks like: not that nothing goes wrong, but that the workflow makes every problem small, visible and fixable.
Next week, Day 11: storage and application state. Making your applications remember things after a refresh, and keeping every piece of state in one predictable place.