A simple Python calculator application designed to teach git merge conflict resolution in 30 minutes.
- Git installed
- Python 3.6+ installed
- Basic understanding of git commands (commit, branch, merge)
-
Clone this repository (if working from remote):
git clone <repository-url> cd SE-merge-conflict-workshop
-
Verify the initial state:
git log --oneline git branch
Run the setup script to create branches with conflicts:
python setup_workshop.pyThis script will:
- Create a
feature-powerbranch that adds a power operation - Create a
feature-modulobranch that adds a modulo operation - Both branches modify the same sections of code, creating merge conflicts
-
Switch to the
feature-powerbranch:git checkout feature-power
Review the changes made in this branch.
-
Switch back to
main:git checkout main
-
Merge
feature-power:git merge feature-power
This should merge successfully.
-
Now try to merge
feature-modulo:git merge feature-modulo
This will create merge conflicts!
-
Open
calculator.pyin your editor. You'll see conflict markers:<<<<<<< HEAD (code from feature-power) ======= (code from feature-modulo) >>>>>>> feature-modulo -
Resolve the conflicts by:
- Keeping both features (power and modulo)
- Removing the conflict markers (
<<<<<<<,=======,>>>>>>>) - Ensuring the code is correct and complete
-
Stage the resolved file:
git add calculator.py
-
Complete the merge:
git commit
(Git will open an editor with a default merge commit message)
-
Test the calculator:
python calculator.py
-
Verify all operations work:
- Addition (+)
- Subtraction (-)
- Multiplication (*)
- Division (/)
- Power (^)
- Modulo (%)
After completing this workshop, you should understand:
- How merge conflicts occur
- How to identify conflict markers in files
- How to resolve conflicts manually
- How to complete a merge after resolving conflicts
- Best practices for avoiding conflicts
If you want to start fresh:
git checkout main
git branch -D feature-power feature-modulo
python setup_workshop.pyTo see what's conflicting:
git status
git diff- Create your own feature branch and merge it
- Practice resolving conflicts with different strategies
- Try using
git merge --abortto cancel a merge - Experiment with
git rebaseinstead of merge
- This workshop is designed to be completed in 30 minutes
- The conflicts are intentionally simple and easy to resolve
- Students should understand both features need to be kept
- Emphasize the importance of testing after resolving conflicts