- Published
- 8 October 2026
- Last reviewed
- 8 October 2026
What you will make
A local practice repository with a main branch and a separate branch containing one reviewed change. Allow about 20 minutes. Nothing in this exercise is uploaded or merged into another project.
Before you start
Use Git 2.28 or later, a terminal with a POSIX-style shell such as Git Bash on Windows, macOS Terminal or Bash on Linux, and a plain-text editor. Run git --version to check that Git is installed. These commands were exercised with Git 2.51.1. Work in a new folder outside any existing repository. Copy commands only, without terminal prompt symbols.
1. Start a practice repository
Run these commands individually:
mkdir rde-git-practice
cd rde-git-practice
git init -b main
Choose an unused folder name if the directory already exists. In this new repository, set a practice identity locally:
git config user.name "Practice Learner"
git config user.email "learner@example.invalid"
These settings apply only to this repository. They do not change your global Git identity.
2. Record a starting point
In your text editor, create README.md inside the practice folder with these two lines:
# Practice project
Purpose: practise reviewing a small change.
Save the file as plain text. Then run:
git add README.md
git commit -m "Add practice README"
git status --short
The last command should produce no output. The starting file is committed and the working tree is clean.
3. Create your branch
Run git switch -c improve-readme, then git branch --show-current. The second command should display improve-readme. Creating the branch alone does not change the file; it gives subsequent commits a separate branch name.
4. Inspect an unstaged change
Append this third line to README.md in your editor and save:
Review: check the purpose and expected result.
Run git diff -- README.md. You should see that line prefixed with a plus sign in the diff. Run git diff --check to check for common whitespace errors. No output means that check found none; it does not establish that the content is correct. Review the wording yourself. If a pager opens, press q to return to the terminal.
5. Review what will be committed
Run git add README.md, then git diff --cached -- README.md. The added line should now appear in the staged diff. A plain git diff should be empty because the working copy matches the staged version. If you edit the file again after staging, review both diffs and stage your intended final change again.
6. Commit and compare the branches
Run git commit -m "Clarify review step", followed by git diff main...HEAD -- README.md. The comparison should show one added content line. Run git status --short; it should be empty. Finally run git switch main and open README.md: the third line should be absent. Run git switch improve-readme and confirm that it returns.
If a command fails
- Git is not recognised: install Git from its official site, reopen the terminal and check the version.
- Nothing to commit: confirm the file was saved and inspect git status.
- A branch already exists: use git switch improve-readme to revisit it; do not force-reset it.
- Switching is blocked by local edits: save your work and inspect the changes before proceeding.
Check your learning
Explain which comparison shows unstaged edits, which shows the staged snapshot and which compares committed branch history. The exercise is complete when the two branch versions differ by the intended line and the working tree is clean.
Official guidance
Git: compare changes with diff
Cover image: AI-generated illustrative scene created specifically for this resource.