Skip to main content

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

  1. Make sure you start from the latest main:
    git switch main
    git pull
    
  2. Create and switch to a feature branch:
    git switch -c improve-readme
    
  3. On improve-readme, edit one specific line of README.md (for example, change the project description line). Commit it with a clear message.
  4. Deliberately create a conflict. Switch back to main and change the same line of README.md differently, 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"
    
  5. Merge your feature branch into main and trigger the conflict:
    git merge improve-readme
    
  6. Resolve the conflict: open README.md, remove the <<<<<<<, =======, >>>>>>> markers, craft the final wording you actually want, then git add README.md and git commit to complete the merge. (See Lesson 3, section 8.)
  7. 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
    
  8. In the Gitea web UI, open a pull request from add-usage-examples into main with a clear title and description of what and why.
  9. 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 -c and committed on it.
  • A genuine merge conflict occurred on the same line of README.md and you resolved it (no conflict markers remain in the file).
  • git log --oneline --graph --all shows the merge commit joining the two lines of work.
  • You pushed a second branch and opened a pull request into main on Gitea.
  • The pull request was reviewed and merged in the Gitea web UI.
  • After merging, git pull on main brings the change down and the feature branch is deleted locally.
  • git status is clean and local main matches origin/main.

Hints

  • Lost in the middle of a conflict and want to start over? git merge --abort returns 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.md should print nothing.
  • git log --oneline --graph --all is the best way to see that the branches merged.
  • If pushing the second branch is rejected, you probably need to git pull on main first; re-read Lesson 4, section 5.
  • Blocked for >~30 min after re-reading the lessons? Bring what you've tried to your mentor.