Menu
Coddy logo textTech

What Is A Merge

Part of the Version Control section of Coddy's Terminal journey — lesson 34 of 58.

A merge brings the work from one branch into another. After a successful merge, the target branch contains every commit from both branches and the files reflect the combined result.

The standard workflow looks like this:

  1. Switch to the branch you want to merge into (usually main).
  2. Run git merge other-branch.
git switch main
git merge feature-login

Git looks at the two branches' histories and figures out how to combine them. Most of the time it does this automatically. The two main flavors of merge are:

  • Fast-forward: main has not moved since the branch was created. Git just slides the main pointer forward.
  • Three-way merge: both branches have new commits. Git creates a new "merge commit" that combines them.

You will see both shapes in the next two lessons.

challenge icon

Challenge

Beginner

The folder contains app.txt. Set up the repo, make a first commit on main, then print the current branch.

This is just a warm-up before merging in the next lesson.

Cheat sheet

A merge brings work from one branch into another. Switch to the target branch first, then merge:

git switch main
git merge feature-login

Two types of merge:

  • Fast-forward: main hasn't moved since the branch was created — Git just moves the pointer forward.
  • Three-way merge: both branches have new commits — Git creates a new merge commit.

Try it yourself

Terminal
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Version Control