git merge Combine another branch into the current one

Brings the changes from a named branch into the branch you are on. If both sides changed the same lines, Git stops and asks you to settle the conflict.

Synopsis

git merge [OPTION]... BRANCH
git merge --abort

Common options

Option or formWhat it does
--no-ffAlways create a merge commit, even when a straight line is possible
--ff-onlyRefuse to merge unless it can simply move forward
--squashCombine all changes into the working folder, ready for one commit
--abortCancel a merge that hit conflicts and go back to before it
-m MESSAGESet the merge commit message

Examples

Merge a feature branch into main
git switch main
git merge feature/search
Merge made by the 'ort' strategy.
 2 files changed, 38 insertions(+)
Always keep a merge commit
git merge --no-ff feature/search
Squash into one commit
git merge --squash feature/search
git commit -m "Add search"
Give up on a messy merge
git merge --abort

Notes

See also

Last reviewed 2026-10-09.