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
| Word | What it means | Example |
|---|---|---|
| Pull request | A request, open for others to read, to join your branch into main. | Add contributing rules |
| Review | Another person reading your change and judging it. | Please fix the typo |
| Push | Sending your commits to the server. | git push |
| Pull | Bringing new commits from the server to your computer. | git pull |
| Commit message | A short note on what a commit changes and why. | Fix login for names with spaces |
| Branch | A separate line of work. | add-contributing |
| Server | A computer that holds the shared copy of the project. | Gitea |
| Repository | A 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.
git config --global user.name "Student"A command for the lesson’s lab terminal. It is shown here and not run.
git config --global user.email "[email protected]"A command for the lesson’s lab terminal. It is shown here and not run.
git clone http://student:student@gitea:3000/student/hello-git.git reviewA command for the lesson’s lab terminal. It is shown here and not run.
cd reviewA 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.
git switch -c add-contributingA command for the lesson’s lab terminal. It is shown here and not run.
echo "Write a clear commit message for every change." > CONTRIBUTING.mdA command for the lesson’s lab terminal. It is shown here and not run.
git add CONTRIBUTING.mdA command for the lesson’s lab terminal. It is shown here and not run.
git commit -m "Add contributing rules"A command for the lesson’s lab terminal. It is shown here and not run.
git push origin add-contributingA command for the lesson’s lab terminal. It is shown here and not run.
3. Open the pull request in Gitea
- In the Gitea tab, sign in as student with the password student. Open student/hello-git.
- Press Pull Requests, then New Pull Request.
- Choose add-contributing to be merged into main. Press New Pull Request again.
- 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:
- Does the change do what the title says?
- Is there anything unexpected?
- 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 questions5. 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.
git switch mainA command for the lesson’s lab terminal. It is shown here and not run.
git pullA command for the lesson’s lab terminal. It is shown here and not run.
git --no-pager log --onelineA command for the lesson’s lab terminal. It is shown here and not run.
A good commit message says what changed
| Poor | Good | Why the good one is better |
|---|---|---|
| fix | Fix login for names with spaces | It says what was fixed |
| changes | Add contributing rules | It says what was added |
| asdf | Remove the old banner from the home page | The 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