Typorithm · medium

merge

git-mergegitmergefast-forwardconflict
Saved on this device
Full lesson · 8 learning steps Open any exercise for focused practice
1

Step 1 of 8 · intro card

Learn merge

0%

Branching

git merge integrates another branch into the current one. A fast-forward just moves the pointer when there is no divergence; --no-ff forces a merge commit to preserve topology; conflicts pause the merge until resolved; --abort backs out; and git log --graph visualizes the DAG.

You merge from the branch you want to keep, so git switch main first, then git merge feature pulls feature's commits into main.

If main has not moved since feature branched off, Git does a fast-forward — it simply advances the main pointer, no merge commit. git merge --no-ff forces a merge commit even when a fast-forward was possible, keeping the branch's shape visible in history.

When both branches changed the same lines, the merge stops with conflicts you must resolve; git merge --abort backs the whole thing out. git log --graph --oneline renders the commit DAG so you can see exactly how the branches came together.

01

Merge runs into the current branch; switch to the target first.

02

A fast-forward moves the pointer with no merge commit.

03

--no-ff forces a merge commit to preserve topology.

git switch main
git merge feature
git merge --no-ff feature
git merge --abort
git log --graph --oneline

Read the implementation

Connect each part of the code to the concept before you type.

1. Go to target

Merge runs from the branch you want to merge into, so switch there first.

git switch main

2. Merge a branch

git merge integrates feature into the current branch, fast-forwarding when there is no divergence.

git merge feature

3. Force a merge commit

--no-ff always creates a merge commit, preserving the branch's topology in history.

git merge --no-ff feature

4. Back out

--abort cancels an in-progress merge and restores the pre-merge state.

git merge --abort

5. Visualize history

--graph --oneline draws the commit DAG so you can see how branches joined.

git log --graph --oneline

A complete learning loop

01

Understand

Read the concept map and follow the code breakdown.

02

Reconstruct

Type the implementation, repair mistakes and work through every recall exercise.

03

Verify

Use the final check without hints; revisit weak concepts in short practice sessions.

merge: Lesson & Practice · Typorithm | ApplyDjinn