Intro to Git — Snapshots, Branches & Sharing
WorkshopyOfficial10 stepsQuiz9 interactiveDiagram
gitversion controlbeginners
GitHub pull request tutorial for teams: branch, push, open, review, fix and merge a pull request in simulated GitHub screens, with exercises.

WorkshopyOfficial
78 lessons · used by 2 teachers
Sign in to copy it to your workspace. It’s free.
12 steps · 2 quizzes · open any step, or read it here
In this GitHub pull request tutorial for teams you practise the whole flow by doing it: branch, push, open a pull request, review it, fix it and merge it. You work on one change in a team's support tool, from the ticket to main, and see each step drawn as it happens.
Here is the whole story in seven moments. Press Play, or step through it.
Interactive · A pull request, from branch to main — try it in the lesson
In this lesson you'll:
It takes about 60 minutes. Each step ends with a "Try it" and one line to remember.
Takeaway: a pull request is a conversation about one change, and main only gets the change once the conversation is done.
A pull request asks to merge one branch into another. Where that branch lives depends on who you are:
Both end in the same place: a pull request into main that people review.
Try it: switch between the two and compare where the branch lives and what you push to.
Interactive · A branch in the team's repository, or in your fork — try it in the lesson
Takeaway: teammates branch in the shared repository; outsiders fork it and open the pull request across repositories.
Ticket #12 says the CSV export of the support tool times out on big queues. You have already changed src/export/csv.js. Before anyone can review it, the change needs its own branch on GitHub:
git switch -c fix/export-timeout makes the branch and moves you onto it.git add src/export/csv.js stages the file.git commit -m "Stream CSV export in batches" records it, with a message that says what it does.git push -u origin fix/export-timeout sends the branch to GitHub; -u remembers it as the branch's upstream, so later a plain git push is enough.Keep each commit about one thing. Reviewers read commits one by one, and a commit titled "stuff" makes them read everything.
Try it: do the four tasks in the practice terminal. git status tells you where you are at any point.
Interactive · Branch, commit and push in a practice terminal — try it in the lesson
With a real repository, make the branch there too, then check that you are on it.
Check your work · Run `git switch -c fix/export-timeout` in a repository of yours, then `git branch --show-current`, and paste what it prints. — check it in the lesson
Takeaway: a pull request starts as a pushed branch; push it with -u the first time.
When the branch is on GitHub, open a pull request from it into main: on the repository's page (GitHub offers Compare & pull request for a branch you just pushed), or with the GitHub CLI: gh pr create.
Closes #12, links the issue and closes it when the pull request merges. The keywords are close, closes, closed, fix, fixes, fixed, resolve, resolves and resolved, and they work only when the base is the repository's default branch.gh pr ready).Try it: fill in the form so all three tasks are done. Change the base to release/2.4 and watch what happens to the closing keyword.
Interactive · Open a pull request that closes its issue — try it in the lesson
Takeaway: a good pull request explains itself before anyone opens the diff, and Closes #12 ties it to its ticket.
You can ask people for a review yourself (the Reviewers box on the right of the pull request, or gh pr create --reviewer sam). Teams also write a CODEOWNERS file (in .github/, the root or docs/): each line is a file pattern and the people or teams who own those files. When a pull request changes owned files, GitHub requests a review from their owners automatically.
Two rules to know:
With the branch protection setting "Require review from Code Owners" (next steps), an owner's approval is needed before merging.
Try it: tick and untick the changed files, and see who gets asked. Then turn on Draft.
Interactive · Which owners a pull request asks for review — try it in the lesson
Takeaway: CODEOWNERS sends each pull request to the people who know those files, and the last matching line decides.
As a reviewer you open Files changed: red lines were removed, green lines added. To check it out and run it yourself, gh pr checkout 14 fetches the branch into your clone.
Try it: find the two lines that need a change, comment on each, then submit the review so it blocks the merge.
Interactive · Review a diff with line comments — try it in the lesson
Takeaway: comment on the line, give the reason, and pick the review type that says what must happen next.
The author doesn't open a new pull request. They fix the code on the same branch and push; every new commit appears in the pull request at once, and a comment on a line that changed is marked Outdated.
git add, git commit -m "Remove debug log" and git push (the upstream is set, so no -u).Avoid rewriting commits a reviewer has already read, with an amend or a force push, while the review is going on: they lose track of what changed since their last look.
Try it: work through both threads, then re-request the review.
Interactive · Push fixes, reply, resolve, re-request — try it in the lesson
Takeaway: answer a review with new commits on the same branch, a reply in each thread, and a re-request.
Four questions on the steps so far.
Question 1. You are not a member of an open-source project and want to propose a fix. What do you do first?
Question 2. Which description line closes issue 12 when the pull request merges into main?
Question 3. A reviewer found a bug that must be fixed before merging. Which review type fits?
Question 4. After a review, how does the author bring the fixes into the pull request?
Two things guard main on most teams:
When a rule isn't met, the merge box says Merging is blocked and lists why. A request for changes counts too: that reviewer must approve a newer version, or the review must be dismissed.
Try it: make the merge button turn on. Then turn off a rule and see what it no longer guards.
Interactive · What the merge box needs before main takes a change — try it in the lesson
Takeaway: checks prove it works, approvals prove someone read it, and branch protection makes both required.
The merge button offers up to three methods (the repository settings decide which):
The pull request below has three commits: the change and two review fixes. main got a commit (M2) since the branch started.
Try it: pick each method and count the new commits on main.
Interactive · Three ways to merge the same pull request — try it in the lesson
Takeaway: merge commit keeps everything, squash keeps one commit per pull request, rebase keeps a straight line with new IDs.
While your pull request waits, teammates merge theirs, and main moves on. GitHub says This branch is out-of-date with the base branch, and the protection setting "Require branches to be up to date before merging" can block the merge until you update.
git fetch origin, git merge origin/main, fix the file, git add, git commit, git push. The previous lesson, on merge conflicts, practises exactly this.Try it: update the branch both ways. Then turn on the same-lines switch.
Interactive · Bring main's new commits into your branch — try it in the lesson
Takeaway: update a waiting branch from main, and resolve a conflict locally, then push.
Pull requests go smoothly when the team agrees on a few things and writes them down, often in CONTRIBUTING.md or the repository's pull request template (.github/pull_request_template.md, which fills every new description):
Try it: pick your team's choices and read the agreement that comes out. Is there one rule your team would add?
Interactive · Draw your team's pull request flow — try it in the lesson
Takeaway: the flow your team agrees on, written down and enforced on main, is what makes pull requests fast.
Seven short exercises. Check each one; a hint costs nothing.
Six questions on the whole flow.
Question 1. What does a draft pull request do?
Question 2. Which words close issue 12 when written before #12, as in "Closes #12"? (pick all)
Question 3. You answer a review comment by pushing a commit that changes that line. What does the comment show?
Question 4. The merge box says "Merging is blocked": 1 of 2 required approvals, all checks passed. What lets it merge?
Question 5. Your team wants main to show one commit per pull request. Which method?
Question 6. The pull request says "This branch has conflicts that must be resolved". What is a safe next step?
Workshopy shares this lesson under CC BY 4.0. Anyone may use and change it, with credit to you. Anyone can learn it here, free. A copy in your workspace is yours to change and run live; your students never need an account.
Version 1Current
· First published
Copies are made from the current version. A copy you already have doesn’t change.
WorkshopyOfficial10 stepsQuiz9 interactiveDiagram
gitversion controlbeginners
WorkshopyOfficial16 steps2 quizzes15 interactiveDiagram
workshopyproduct touronboarding
WorkshopyOfficial10 steps2 quizzes10 interactive
data-literacystatisticsmean and median
WorkshopyOfficial12 steps2 quizzes15 interactive
pythonfunctionsreturn values
WorkshopyOfficial12 steps2 quizzes11 interactive
devopsregexregular expressions
WorkshopyOfficial11 steps2 quizzes11 interactive
devopsdockercontainers
Comments
No comments yet. Be the first to say how it went.