Skip to content
BENIBIX Learn

Merge

Development🔀 Version ControlBranches and History

Also known as Git Merge

Joining work from one branch into another. Both sets of changes end up in one place.

Think of it like

Think of it like two streams meeting to make one river. The water from both ends up in one place.

Example

Emma finishes dark-mode and merges it into main. Her new style is now part of the main code.

Why it matters

Merging is how separate work becomes one product. It happens many times a day on a busy team.

Definition

A merge joins the work from one branch into another. Git compares the two lines of commits and combines the changes. If only one side moved on, Git just moves the branch forward, which is called a fast-forward. If both sides changed, Git makes a new merge commit that ties them together. If both changed the same lines, you get a merge conflict to sort out by hand.

Example code

console
$ git merge dark-mode
Updating 6dd6d2c..d331bff
Fast-forward
 style.css | 1 +
main had not moved, so Git simply caught it up to dark-mode.

Common mistake

Merging without pulling first. You merge into an old copy and then hit surprises when you push.

Key takeaways

  1. 1
    Two lines become one. Changes from both sides are joined.
  2. 2
    Fast-forward if it can. No new commit when one side is still.
  3. 3
    Conflicts need you. Same lines changed means a choice.

Compare

Learn it properly