US Trends

what does git merge do

Git merge combines changes from one branch into another, usually by creating a new merge commit that preserves both branches’ history. It’s how you bring finished work from a feature branch back into main without losing the separate commit trail.

What it does

  • Finds the common base commit between the branches.
  • Applies the changes from the other branch onto your current branch.
  • Updates the branch history, often with a merge commit that has two parents.

Why people use it

  • To integrate feature work into the main line of development.
  • To keep history intact instead of rewriting commits.
  • To combine parallel work from multiple people or branches.

Conflicts

If both branches changed the same part of a file, Git can’t safely choose for you and will mark a conflict for manual resolution. Those conflict markers are how Git shows you where the overlap happened.

Simple example

If feature has new commits and main has also moved forward, running git merge feature while on main brings the feature changes into main and records the combined result.

TL;DR: git merge is the command for joining branch histories and combining their changes, usually without deleting either branch’s work.