AtomLearnAtomLearn
DashboardGoalsPathAchievementsReviewSign In
DashboardGit & Version ControlMerging & Conflict Resolution
Git & Version ControlNot Started

Merging & Conflict Resolution

Integrate branches with merge and rebase, and resolve conflicts when they arise

0%
Knowledge0%
Learn & Drill
Fluency0%
Drill & Speed
Retention0%
Mastery & Review
Confidence0%
All modes
Practice
Knowledge
Fluency
Retention

Knowledge Debt detected

You can study this freely — but your score may plateau if these foundations have gaps. The Mastery badge requires them to be solid.

Explanation

Merging integrates the changes from one branch into another.

bash
git switch main
git merge feature-login   # bring feature-login changes into main

Fast-forward merge — if main has no new commits since the branch split off, Git just moves the main pointer forward. No merge commit, linear history.

3-way merge — if both branches have diverged, Git creates a merge commit that ties them together.

Merge conflicts happen when the same lines were changed differently in both branches. Git marks them:

<<<<<<< HEAD
color: blue;         ← your current branch
=======
color: red;          ← incoming branch
>>>>>>> feature-ui

You edit the file to keep what you want, remove the markers, then:

bash
git add conflicted-file.css
git commit   # completes the merge

Rebase — alternative to merge. Replays your commits on top of the target branch, producing a linear history:

bash
git switch feature-login
git rebase main   # replay feature-login commits on top of main

Examples

Merge a feature branch into main

Always switch to the target branch first, then merge the source into it.

git switch main
git merge feature-login
# If fast-forward: no merge commit, history stays linear
# If diverged: Git opens editor for a merge commit message

Resolve a merge conflict

Conflicts are normal in team work. The key steps: edit the file, stage it, commit.

git merge feature-ui
# CONFLICT (content): Merge conflict in styles.css
# Open styles.css, find <<<< markers, edit to desired state
# Remove all <<<, ===, >>> lines
git add styles.css
git commit   # Git pre-fills the merge commit message

How well did you understand this?

Next in Git & Version Control

Remotes, GitHub & Push/Pull

Continue