git-merge
Combine changes from one branch into another
TLDR
Merge a branch into your current branch
Edit the merge message
Merge a branch and create a merge commit
Abort a merge in case of conflicts
Merge using a specific strategy
SYNOPSIS
git merge [options] <commit>…
PARAMETERS
-n, --no-summary
Do not show diffstat summary
--stat
Show diffstat of changes
--no-commit
Perform merge but do not autocommit
--squash
Create single commit summarizing changes
--edit, -e
Edit default merge message
--no-edit
Do not edit merge message
-s <strategy>, --strategy=<strategy>
Select merge strategy (e.g., recursive, ort, octopus)
-X <option>, --strategy-option=<option>
Pass strategy-specific option
--allow-unrelated-histories
Merge unrelated histories
-m <msg>
Set merge message
-F <file>, --file=<file>
Read merge message from file
--abort
Abort and reset to pre-merge state
--continue
Continue merge after resolving conflicts
--quit
Quit merge without changes
--ff-only
Fast-forward only, refuse merge commit
--no-ff
Always create merge commit
DESCRIPTION
The git merge command integrates changes from one or more branches into the current branch, creating a merge commit if necessary. It supports fast-forward merges when possible, avoiding extra commits, or three-way merges using a common ancestor. If conflicts arise, Git pauses for manual resolution before committing.
Key features include selectable merge strategies like recursive (default), ort (modern performant), resolve, and octopus for multiple parents. Options control commit creation, editing messages, and handling unrelated histories. Post-merge states allow --abort to reset, --continue after fixes, or --quit to detach.
Common use: git merge main to integrate main into feature branch. Always commit or stash changes first to avoid issues. Enhances collaborative workflows by combining histories without overwriting.
CAVEATS
Fails if working tree dirty; use git stash first. Warns on detached HEAD. Conflicts require manual edits and git add before continue. Not for rebasing histories.
FAST-FORWARD VS MERGE COMMIT
Fast-forwards if linear history possible (<b>--ff</b> default); use <b>--no-ff</b> for explicit merges to preserve branch structure.
CONFLICT RESOLUTION
Git marks conflicts with <<< ===== >>>; edit files, <b>git add</b>, then <b>git merge --continue</b>.
HISTORY
Introduced in Git 0.99 (2005) by Linus Torvalds. Evolved with strategies: recursive default since v0.99, resolve added early. ort (Optimized Recursive Tree) became default in Git 2.34 (2021) for speed. Supports multi-parent octopus since v1.5. Usage grew with distributed workflows.
SEE ALSO
git-branch(1), git-pull(1), git-rebase(1), git-cherry-pick(1), git-push(1)


