Back to roadmap

Lesson 07

Merge

Merge is a Git history operation: it combines another branch into the branch you currently have checked out.

Visual Explanation

Ready to run git merge --no-ff feature/login.

Keep These Ideas

Receiving branch
The branch you are on receives the other branch's commits.
Merge commit
A checkpoint that connects both lines of history. This is separate from a hosted review page.
Conflict
Git asks for help when it cannot combine overlapping changes automatically.

The Real Command

Terminal
git merge --no-ff feature/login
Example Output
Merge made by the 'ort' strategy.
 app.js | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Run this from main to combine feature/login and keep a visible merge checkpoint.

Command Details

git switch main

Choose the receiver first. Switch to main before merging the feature into it.

git merge feature/login

Default merge. Git chooses a fast-forward or merge commit when appropriate.

Example Output
Updating a1b2c3d..d4e5f6a
Fast-forward
 app.js | 12 ++++++++++++
 1 file changed, 12 insertions(+)
git merge --abort

--abort cancels an unfinished merge. Use it to return to the pre-merge state when a conflict becomes confusing.

Knowledge Check

Join Two Lines of Work

Use Git to combine histories while understanding the receiving branch, merge commits, and conflicts.

Question 1 of 5

  1. Question 1: current
  2. Question 2: not started
  3. Question 3: not started
  4. Question 4: not started
  5. Question 5: not started
Command Challenge

You are on main. Merge feature/login and keep an explicit merge checkpoint even if Git could fast-forward.