Resolving a merge conflictProLesson 25 of 45, about 8 min
- 1
- 2
- 3
- 4
- 5
- 6
- 7
The app: Forge, a code host
Forgeharbor / harbor-appPull request #231
feat(billing): annual plans get 20% off #231
This branch has conflicts that must be resolvedConflicting file:
lib/billing/discounts.jsKofi’s fix #212 is already on main.
The file, the history and the tests
Terminal you rangit merge main
$ git merge main
Auto-merging lib/billing/discounts.js
CONFLICT (content): Merge conflict in lib/billing/discounts.js
Automatic merge failed; fix conflicts and then commit the result.
lib/billing/discounts.js as git left it1 conflict
// How much to take off a plan's price, in cents.
function discountCents(plan, coupon) {
return (plan.priceCents * percent) / 100;
=======
const percent = coupon?.percentOff ?? 0;
}
git log --graph --oneline two branches since 9d73fc3
* 7d2e1f4 (HEAD -> feat/annual-discount) feat(billing): annual plans get 20% off
| * a41c9e2 (main) fix(billing): round discounts to whole cents (#212)
|/
* 9d73fc3 feat(billing): coupons take a percentage off
a41c9e2, Kofi, 6 days ago:
Stripe only takes whole cents. 1999 × 15% was 299.85,
and those invoices failed to finalize.
The MagisterThis is Forge, the code host Harbor’s team uses. Your pull request gives annual plans 20% off, but it can’t merge: while you worked, someone changed the same lines on main. Press Resolve conflicts. On the right is what git said when you ran git merge main.
Step 1 of 7Open the conflict
- Open the conflict editor
You’re not signed in, so this lesson won’t be saved to your path. Sign in free to keep your XP.