Assignment 2: Branch, conflict, resolve, and open a PR
Goal: Practice the full collaboration loop — create a feature branch, deliberately cause a merge conflict, resolve it correctly, and land your change through a pull request on Gitea.
Where: On your lab VM, in the module3-scripts repository you pushed in Assignment 1. The remote is the lab Gitea server — public URL https://git.example.com, internal http://10.100.100.2:3000.
Tasks
- Make sure you start from the latest
main:git switch main git pull - Create and switch to a feature branch:
git switch -c improve-readme - On
improve-readme, edit one specific line ofREADME.md(for example, change the project description line). Commit it with a clear message. - Deliberately create a conflict. Switch back to
mainand change the same line ofREADME.mddifferently, then commit:git switch main # edit the same README line a different way git add README.md git commit -m "Reword project description on main" - Merge your feature branch into
mainand trigger the conflict:git merge improve-readme - Resolve the conflict: open
README.md, remove the<<<<<<<,=======,>>>>>>>markers, craft the final wording you actually want, thengit add README.mdandgit committo complete the merge. (See Lesson 3, section 8.) - Now practice the PR flow on a new branch so there's something to review. From the resolved
main:git switch -c add-usage-examples # add a "Usage" section to README.md, then: git add README.md git commit -m "Add usage examples to README" git push -u origin add-usage-examples - In the Gitea web UI, open a pull request from
add-usage-examplesintomainwith a clear title and description of what and why. - Have your mentor (or a teammate) review it. Then merge the PR in Gitea, and locally:
git switch main git pull git branch -d add-usage-examples
Deliverable
A module3-scripts repo on Gitea showing: a merge commit that resolved a real conflict, and a merged pull request from add-usage-examples into main. Your local main matches origin/main.
Acceptance criteria — you're done when:
- You created a feature branch with
git switch -cand committed on it. - A genuine merge conflict occurred on the same line of
README.mdand you resolved it (no conflict markers remain in the file). -
git log --oneline --graph --allshows the merge commit joining the two lines of work. - You pushed a second branch and opened a pull request into
mainon Gitea. - The pull request was reviewed and merged in the Gitea web UI.
- After merging,
git pullonmainbrings the change down and the feature branch is deleted locally. -
git statusis clean and localmainmatchesorigin/main.
Hints
- Lost in the middle of a conflict and want to start over?
git merge --abortreturns you to the pre-merge state. - The final resolved line should be exactly what you want the file to read — you are not forced to pick one side; you can blend them.
- Verify no markers slipped through:
grep -n '<<<<<<<\|=======\|>>>>>>>' README.mdshould print nothing. git log --oneline --graph --allis the best way to see that the branches merged.- If pushing the second branch is rejected, you probably need to
git pullonmainfirst; re-read Lesson 4, section 5. - Blocked for >~30 min after re-reading the lessons? Bring what you've tried to your mentor.
No comments to display
No comments to display