Merge

Merging combines the changes from one branch into another, typically bringing a finished feature branch back into main. Git joins the two histories into a single line of work.

Git & DevOps

When the branches don't have conflicting edits, Git merges them automatically. If both branches changed the same lines, Git stops and asks you to resolve a merge conflict by hand.

A 'fast-forward' merge happens when the target branch hasn't changed — Git simply moves its pointer forward instead of creating a merge commit.

Syntax

git merge <branch>

Examples

Bash

git switch main
git merge feature-login

Output:

Updating 9f3a21c..4b8c7d2
Fast-forward
 login.html | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Learn it in a lesson

See also

Back to the Dictionary