1.1 KiB
DEMO: Git Conflict
Before the demo:
cp -r src\ git-conflict-demo-repo
cd git-conflict-demo-repo\
git init
git checkout -b main
git add calculator.ts
git commit -m "initial commit"
During the demo:
-
Create a feature branch
git branch fix-multiplication
-
Checkout to branch
git checkout fix-multiplication
-
Fix the multiplication function
-
Add & Commit changes
git add calculator.ts
git commit -m "fix multiplication"
-
Note that we did not merge the changes yet, they are in the feature branch
-
Checkout to main
git checkout main
-
Checkout to another feature branch
git branch fix-calculator
-
Make conflicting changes
-
Add & Commit changes
git add calculator.ts
git commit -m "fix calculator"
-
Checkout to main
git checkout main
-
Merge the changes
git merge fix-calculator
-
Try to merge the changes from the first branch
git merge fix-multiplication
-
Observe the conflict message
-
Fix the source code
-
Add & Commit the changes
git commit -am "fix merge conflict"
-
Observe the finished product