Practice¶
This section contains step-by-step exercises. Each one is self-contained: you can follow them in order or jump to whichever interests you.
Before starting
Make sure you have Git installed and configured as we saw in Workspace, and the SSH connection with GitHub ready per SSH Connection.
Exercise 1 · First commit¶
Goal: create a local repository, make a change, and confirm it. Estimated time: 10 minutes.
Step 1 · Create the folder¶
Step 2 · Initialize Git¶
You should see:
Step 3 · Configure the default branch (optional)¶
If you haven't configured init.defaultBranch=main globally yet:
Step 4 · Create a file¶
Step 5 · Check the status¶
You'll see:
On branch main
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
README.md
nothing added to commit but untracked files present (use "git add" to track)
Step 6 · Add to staging¶
Step 7 · Make the first commit¶
Expected result
Step 8 · See the history¶
You'll see your first commit with its short hash.
Exercise 2 · Resolve a conflict¶
Goal: simulate a merge conflict and resolve it manually. Estimated time: 15 minutes.
Step 1 · Prepare the repository¶
mkdir conflict-demo && cd conflict-demo
git init && git checkout -b main
echo "Line 1" > greeting.txt
echo "Line 2" >> greeting.txt
git add greeting.txt
git commit -m ":sparkles: Initial version of greeting"
Step 2 · Create a branch with a change¶
git switch -c feature/greeting
echo "Hello, world!" > greeting.txt
git commit -am ":sparkles: Greeting in English"
Step 3 · Go back to main and make a different change¶
Step 4 · Try the merge¶
Git can't decide which version of the file to keep:
Auto-merging greeting.txt
CONFLICT (content): Merge conflict in greeting.txt
Automatic merge failed; fix conflicts and then commit the result.
Step 5 · Inspect the conflict¶
You'll see the markers:
Step 6 · Resolve by hand¶
Edit the file and keep only the version you want:
(In real life, you probably want to keep both lines or choose carefully.)
Step 7 · Confirm the resolution¶
Exercise 3 · Pull Request with code review¶
Goal: simulate a complete collaboration flow on GitHub: create a branch, make a change, open a PR, receive feedback, apply it, and merge. Estimated time: 30 minutes.
Step 1 · Create the repository on GitHub¶
- Go to github.com/new.
- Name:
practice-pr. - Check Add a README file.
- Click Create repository.
Step 2 · Clone and create a branch¶
git clone git@github.com:YOUR_USER/practice-pr.git
cd practice-pr
git switch -c docs/add-installation
Step 3 · Make a change¶
Edit README.md and add a section:
(Use triple backticks in the actual file.)
Step 4 · Commit and push¶
git add README.md
git commit -m ":books: Document installation in README"
git push -u origin docs/add-installation
Step 5 · Open the PR¶
- Go to the URL GitHub shows after the push.
- Click Compare & pull request.
- Title:
Document installation in README. - Description: explanation of what you added and why.
- Mark as Draft.
- Click Create pull request.
Step 6 · Receive feedback¶
Imagine a reviewer comments:
"Missing prerequisites (Node.js >= 18)."
Step 7 · Apply the feedback¶
Edit README.md:
Commit and push:
The PR updates automatically with the new commit.
Step 8 · Approve and merge¶
- Mark the PR as Ready for review.
- Approve (yourself in this exercise).
- Squash and merge.
- Delete the branch.
Exercise 4 · Configure branch protection¶
Goal: apply protection rules to the main branch from the
GitHub UI. Estimated time: 10 minutes.
Only applies to repositories where you're an admin
If it's your personal repo, perfect. If it's an organization's, ask for admin access first.
Step 1 · Go to Settings → Branches¶
github.com/YOUR_USER/practice-pr/settings/branches
The first step is to navigate to the Settings tab of the repository. In the screenshot below, the tab is highlighted in orange at the right of the repo header:

Image: Settings tab in a GitHub repository header.
Step 2 · Add a rule for main¶
- Click Add rule.
- Branch name pattern:
main. - Enable:
- ☑ Require a pull request before merging.
- ☑ Require approvals:
1. - ☑ Dismiss stale pull request approvals when new commits are pushed.
- ☑ Require linear history (no merge commits).
- ☑ Do not allow force pushes.
- ☑ Do not allow deletions.
- Click Create.
Step 3 · Test that it works¶
You should receive an error:
That confirms the protection works. To make changes to main now,
you have to do them via Pull Request.
Additional resources¶
- Git Official Tutorial.
- Oh My Git! — game to learn Git visually.
- Learn Git Branching — interactive tutorial with visualizations.
- GitHub Skills — short official courses.
Next step¶
Go back to Home to review all the material or explore the Glossary.