Why this matters
Common mistakes and self-check
- Leaving conflict markers in files.
- Self-check: search your repo for <<<<<<< or >>>>>>> before committing.
- Choosing an entire side when a blended solution is needed.
- Self-check: reconsider business logic (e.g., currency vs USD standardization).
- Forgetting the final step.
- Merge needs
git commit; rebase needsgit rebase --continue.
- Merge needs
- Formatting churn causing avoidable conflicts.
- Self-check: run formatters/pre-commit hooks before merging to normalize JSON/YAML/SQL style.
- Merging generated/binary files.
- Self-check: mark them in
.gitattributesto avoid merge (e.g., usemerge=oursfor build artifacts).
- Self-check: mark them in
Exercises
Mirror of the interactive exercises below. Do them locally in a scratch repo.
Exercise 1 — Resolve a SQL conflict by blending logic
- Initialize a repo; create
models/revenue.sqlwith a simple SELECT and commit. - Branch A (main): rename a column; commit.
- Branch B (feature): add new columns; commit.
- Merge feature into main; resolve conflict by combining columns thoughtfully.
- Stage and commit. Validate the SQL reads clearly.
- Checklist:
- Markers removed.
- Column names consistent with team standards.
- Final merge commit message explains the decision.
Exercise 2 — Take theirs for JSON layout, keep local theme/title
- Create
dashboards/sales.jsonwith theme, title, and layout; commit. - On main: change layout; commit.
- On feature: change theme to dark and improve title; commit.
- Merge feature into main. Use
git checkout --theirsto take layout, then re-apply your theme/title edits. - Stage and commit with an explanatory message.
- Checklist:
- Valid JSON (no trailing commas, consistent quotes).
- Layout from incoming branch, theme/title from yours.
- No conflict markers left.
Practical projects
- Team merge lab: Two teammates intentionally edit the same chart config and practice resolving 3 different conflict styles (take ours, take theirs, blend).
- SQL refactor rollout: Rename a common dimension and handle the cascade of conflicts across 5 models, committing clear rationale at each resolution.
- Repo hygiene: Add formatters and a
.gitattributesfile to reduce future conflicts; simulate before/after by running merges.
Mini challenge
You are merging a feature that adds fx_rate and currency into a dashboard while main renamed revenue to revenue_usd and changed widget order. Decide a resolution plan in 3 steps: which columns to keep/rename, which layout to choose, and one sentence commit message explaining why.
Possible approach
- Columns: keep
revenue_usdand includefx_rate,currencyfor context. - Layout: take theirs (latest) to minimize downstream surprises.
- Commit msg: "Merge: standardize on revenue_usd; keep fx_rate/currency for display; adopt latest layout."
Learning path
- Practice reading and removing conflict markers quickly.
- Resolve conflicts in SQL, then JSON/YAML files.
- Handle rebase conflicts and continue/abort confidently.
- Add repo policies to prevent noisy conflicts (formatters, .gitattributes).
- Explain your merge decisions in clear commit messages.
Next steps
- Adopt a branching model (e.g., trunk or short-lived feature branches).
- Use code reviews to catch risky merges before they happen.
- Automate formatting and validation with pre-commit and CI to reduce conflicts.
Tip: Reducing future conflicts
- Keep PRs small and focused.
- Pull/rebase frequently.
- Normalize formatting for JSON/YAML/SQL.
- Do not version build artifacts; mark binary/generated files in
.gitattributes.
Quick test & progress: The quick test is available to everyone. Log in to save your progress; otherwise, you can still take it for practice.