Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Free lesson

OS 8.3 (4 of 4): Git: pull requests and review

The whole lesson, free. Read it and have a go at the activities. To work the tasks and labs in the real lesson, press Start lab, with no account needed.

40 minutes

A quick check that you are not a bot, then your own lab opens on the interactive lesson.

Already have an account? Sign in

Another person reads it first

You fix a bug and merge it. Later the site breaks. You did not see the mistake in your own change.

Teams use review to solve this. Before a change joins the shared code, somebody else reads it. A pull request is the tool for this. It asks to join your work into the main code, and others can read it first.

Key words

WordWhat it meansExample
Pull requestA request, open for others to read, to join your branch into main.Add contributing rules
ReviewAnother person reading your change and judging it.Please fix the typo
PushSending your commits to the server.git push
PullBringing new commits from the server to your computer.git pull
Commit messageA short note on what a commit changes and why.Fix login for names with spaces
BranchA separate line of work.add-contributing
ServerA computer that holds the shared copy of the project.Gitea
RepositoryA folder of files and their whole history.hello-git

The cells students fill in are left blank in this preview.

Start the lab first

Note

Press Start the lab on the bar at the top of this lesson. Wait until it says it is running. Press Gitea on the same bar to open it in a second tab. Keep that tab open: you use it in step 3.

A change is reviewed before it merges

flowchart LR
  branch[Work on a branch] --> push[Push the branch to the server]
  push --> pr[Open a pull request]
  pr --> review[Somebody reviews it]
  review --> ok{Good?}
  ok -->|no| change[Change it and push again]
  change --> review
  ok -->|yes| merge[Merge into main]
  merge --> pull[Everyone pulls the new main]

1. Clone a fresh copy

Tell Git your name and email. Then clone the project (make your own copy) into a folder called review. Then go into the folder.

Command
git config --global user.name "Student"

A command for the lesson’s lab terminal. It is shown here and not run.

Command
git config --global user.email "[email protected]"

A command for the lesson’s lab terminal. It is shown here and not run.

Command
git clone http://student:student@gitea:3000/student/hello-git.git review

A command for the lesson’s lab terminal. It is shown here and not run.

Command
cd review

A command for the lesson’s lab terminal. It is shown here and not run.

2. Make a change on a branch

Add a file with a rule for the team. Then push (send) the branch to the server. The branch is now on the server, and main has not changed.

Command
git switch -c add-contributing

A command for the lesson’s lab terminal. It is shown here and not run.

Command
echo "Write a clear commit message for every change." > CONTRIBUTING.md

A command for the lesson’s lab terminal. It is shown here and not run.

Command
git add CONTRIBUTING.md

A command for the lesson’s lab terminal. It is shown here and not run.

Command
git commit -m "Add contributing rules"

A command for the lesson’s lab terminal. It is shown here and not run.

Command
git push origin add-contributing

A command for the lesson’s lab terminal. It is shown here and not run.

3. Open the pull request in Gitea

  1. In the Gitea tab, sign in as student with the password student. Open student/hello-git.
  2. Press Pull Requests, then New Pull Request.
  3. Choose add-contributing to be merged into main. Press New Pull Request again.
  4. Write a title. Press Create Pull Request.

4. Review the change, then merge

Open the Files Changed tab. This is what a reviewer reads. Ask these questions:

  1. Does the change do what the title says?
  2. Is there anything unexpected?
  3. Is the commit message clear?

If it is good, go back to the Conversation tab. Press the green merge button, then press it again to confirm.

Check: what a review does

Have a go

Check: what a review does

3 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

5. Pull the merge to your computer

The merge happened on the server. Your computer does not know yet. Go to main and pull (get the new commits). Then read the history.

Command
git switch main

A command for the lesson’s lab terminal. It is shown here and not run.

Command
git pull

A command for the lesson’s lab terminal. It is shown here and not run.

Command
git --no-pager log --oneline

A command for the lesson’s lab terminal. It is shown here and not run.

A good commit message says what changed

PoorGoodWhy the good one is better
fixFix login for names with spacesIt says what was fixed
changesAdd contributing rulesIt says what was added
asdfRemove the old banner from the home pageThe next person can find it in the history

The cells students fill in are left blank in this preview.

Match each word to what it does

Have a go

Loading…

Your answers are marked here and are not kept. A college account keeps every student’s marks.

Final check

Have a go

Final check

4 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Teach this lesson with your class

On a college account your students work the tasks and the labs as well, and every mark is kept for you.