Thuta Learning
ExercisesDevOps & Toolsbeginner

Exercise: Branch & Remote Workflow Practice

Relax. We'll talk through this in plain words — no textbook voice.

What you'll walk away with

  • Practice Exercise: Branch & Remote Workflow Practice yourself, hands-on
  • Practice the skills you've already learned and make them solid
  • Get good at finding mistakes, fixing them, and checking your own work

Let's think about it this way for a second

This exercise set combines the branching, merging, remote collaboration, conflict resolution, and reset skills you learned in the Intermediate and Advanced chapters into one challenge. It's tougher than the first exercise set, with scenarios that are closer to a real project workflow. Working through each task is meant to build your confidence using the Git command line.

Exercises

Task 1: In an existing repository, create a new branch called feature/dark-mode, edit a file, commit it, then merge it back into main. Task 2: Edit the same line of the same file differently on both the main branch and the feature branch, so that a conflict occurs during the merge on purpose, then resolve it. Task 3: Connect a local repository to a GitHub remote (an empty repo), push two commits, then undo one commit with git reset --mixed, recommit, and see whether you can push again without a force-push (note that git push --force will be needed).

Code Example

bash
# Task 1: feature branch merge
git switch -c feature/dark-mode
echo "body { background: #111; color: #eee; }" >> style.css
git add style.css
git commit -m "Add dark mode styles"
git switch main
git merge feature/dark-mode

# Task 2: intentional conflict
git switch -c feature/header-text
# style.css line 1 ကို ပြင်ပါ, commit လုပ်ပါ
git switch main
# style.css line 1 ထပ်ကွဲပြားအောင် ပြင်ပါ, commit လုပ်ပါ
git merge feature/header-text
# CONFLICT ကို ဖွင့်ကြည့်ပြီး ဖြေရှင်းပါ
git add style.css
git commit -m "Resolve style.css conflict"

# Task 3: reset + remote sync
git remote add origin https://github.com/<your-username>/practice-repo.git
git push -u origin main
git commit -m "Bad commit to undo" --allow-empty
git reset --mixed HEAD~1
git status
git commit -m "Corrected commit"
git push origin main
You should see
After completing all the tasks, the local history is conflict-free, and the GitHub remote branch matches the local main branch exactly.

Try it in 5 minutes

Redo Task 2, but this time, when resolving the conflict, keep the incoming (feature) version instead of the HEAD version (5 minutes).

A quick word of caution

If you reset a commit locally after it's already been pushed to the remote, pushing again will diverge the history — so use git push --force with great caution on a branch shared with a team.

Easy traps

  • Running git commit directly after resolving a merge conflict without running git add first, so the commit can't actually complete
  • Running an ordinary git push after git reset --mixed instead of force-pushing, and hitting a 'rejected' error (because the histories have diverged)

Now try it yourself

Redo Task 2, but this time, when resolving the conflict, keep the incoming (feature) version instead of the HEAD version (5 minutes).

You'll know it worked when: After completing all the tasks, the local history is conflict-free, and the GitHub remote branch matches the local main branch exactly.

Exercise: Branch & Remote Workflow Practice | Thuta Learning