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:
- Switch to the branch you want to merge into (usually
main). - Run
git merge other-branch.
git switch main
git merge feature-loginGit 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:
mainhas not moved since the branch was created. Git just slides themainpointer 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
BeginnerThe 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-loginTwo types of merge:
- Fast-forward:
mainhasn'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
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Version Control
2Getting Started
Initialize A RepositoryThe .git FolderConfigure Your IdentityGit StatusRecap - First Repo8Merging
What Is A MergeFast-Forward MergeThree-Way MergeMerge ConflictsResolve A ConflictRecap - Merge Master11Feature Branch Project
Project OverviewInitialize Main3Tracking Changes
The Staging AreaGit AddGit CommitModifying A Tracked FileGit LogRecap - First Commits6Recipe Site Project
Project OverviewInitialize And Ignore