Before this lesson
Understand branches, ordinary merges and status.
Use Git 2.35+ and a Bash-compatible terminal, such as Git Bash on Windows. Each complete example creates an independent temporary directory. Run it only in that practice repository. Configuration is repository-local and uses a practice identity. Temporary directories are not automatically removed; clean them up after finishing.
What you will be able to do
Reproduce a same-line conflict, inspect it and complete the merge.
Understand the mechanism
When branches edit the same area from a common ancestor, Git may be unable to choose a result. A conflict pauses the merge for a decision rather than meaning all data is lost.
Use status and diff --name-only --diff-filter=U to identify unresolved files. Marked text represents both sides. Do not merely delete markers without considering intent. Here we combine two learning suggestions.
After editing, git add marks the file resolved and commit finishes the merge. To abandon before committing, use git merge --abort. Starting clean reduces recovery complexity.
Runnable example
lab=$(mktemp -d)
cd "$lab"
git init -b main .
git config user.name "Honeysuck Learner"
git config user.email 'learner'@'example.invalid'
git config commit.gpgsign false
git config core.autocrlf false
printf 'Start learning\n' > notes.txt
git add notes.txt
git commit -m "Start learning notes"
git switch -c feature/route
printf 'Start with HTML\n' > notes.txt
git add notes.txt
git commit -m "Suggest HTML first"
git switch main
printf 'Start with Git\n' > notes.txt
git add notes.txt
git commit -m "Suggest Git first"
if git merge feature/route; then
printf 'No conflict occurred; inspect your earlier steps.\n'
else
git status --short
git diff --name-only --diff-filter=U
fi
printf 'Start with Git, then build HTML\n' > notes.txt
git add notes.txt
git commit -m "Combine both learning routes"
cat notes.txt
git status --short
Trace and verify
The merge should show UU notes.txt. After resolution, the file reads Start with Git, then build HTML. Status is clean and the merge commit has two parents.
Common mistakes and boundaries
The example intentionally handles a nonzero merge exit using if. Real merges can fail for other reasons: inspect errors and unresolved files before editing, rather than blindly overwriting content.
Practice challenge
Rerun independently, abort after the conflict and inspect main.
Reference solution and reasoning
After abort, main retains Start with Git and feature/route retains Start with HTML. No merge commit is created for the aborted attempt.