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 form | What it does |
|---|---|
--no-ff | Always create a merge commit, even when a straight line is possible |
--ff-only | Refuse to merge unless it can simply move forward |
--squash | Combine all changes into the working folder, ready for one commit |
--abort | Cancel a merge that hit conflicts and go back to before it |
-m MESSAGE | Set the merge commit message |
Examples
git switch main
git merge feature/search
Merge made by the 'ort' strategy.
2 files changed, 38 insertions(+)
git merge --no-ff feature/search
git merge --squash feature/search
git commit -m "Add search"
git merge --abort
Notes
- Conflicted files contain markers: <<<<<<<, =======, >>>>>>>. Edit them, then git add the files and run git commit.
- Merge into the branch you are standing on. Switch first.
- Run git status during a conflict to see exactly which files need attention.
See also
Last reviewed 2026-10-09.