ADVERTISEMENT
Google AdSense Slot (headerLeaderboard)

Set your Publisher ID in src/config/ads.ts to display live ads.

Git Version Control Tutorial• 7 min read

Merging Branches & Conflict Resolution

Fast-Forward vs 3-Way Merges, diff markers, and resolving conflicting lines

Merging integrates isolated commits from a feature branch back into a target branch (like main). When conflicting lines are touched by both branches, Git halts for human resolution.

Fast-Forward vs 3-Way Merge

Fast-Forward Merge: Occurs when main has no new commits since the feature branched. Git simply moves the main pointer forward to the feature branch commit.

3-Way Merge: Occurs when both main and the feature branch have diverged with independent commits. Git creates a new "Merge Commit" uniting both histories.

Merge Conflict: Happens when two branches modified the exact same lines in a file. Git injects conflict markers (<<<<<<< HEAD, =======, >>>>>>>).

Resolving a Merge Conflict
// File showing Git conflict markers:
<<<<<<< HEAD
const API_URL = "https://production.codexia.org/api";
=======
const API_URL = "https://staging.codexia.org/api";
>>>>>>> feature/staging-env

// Resolution: Manually edit file to desired code, delete markers:
const API_URL = process.env.NEXT_PUBLIC_API_URL || "https://production.codexia.org/api";

// Then stage and commit the resolution:
// git add api.js
// git commit -m "fix: resolve merge conflict in API endpoint configuration"
Edit files to keep desired code, remove conflict markers, then stage and commit.
ADVERTISEMENT
Google AdSense Slot (inContentBanner)

Set your Publisher ID in src/config/ads.ts to display live ads.

Test Yourself With Exercise

+15 XP

What should you do after manually editing a conflicted file and removing conflict markers (`<<<<<<<`, `=======`, `>>>>>>>`)?