Git 2 reference · Branching and Merging
git merge Command (Git)
Combine another branch into the current one, fast-forwarding when possible or creating a merge commit.
Git 2
Syntax
git merge [--no-ff] [--abort] BRANCH
Parameters
| Parameter | Description |
|---|---|
--no-ff |
Always create a merge commit. |
--ff-only |
Refuse unless it can fast-forward. |
--abort |
Give up a conflicted merge. |
Examples
git init -q -b main app && cd app
echo '# Shop' > README.md
git add README.md && git commit -q -m 'Initial commit'
git switch -q -c feature
echo f > feature.txt; git add .; git commit -q -m 'Add feature'
git switch -q main
git merge -q feature && git log --oneline
Output
c0ec713 Add feature 7f7f133 Initial commit
Run this on your computer — see “Get Started” for setup.
git init -q -b main app && cd app
echo '# Shop' > README.md
git add README.md && git commit -q -m 'Initial commit'
git switch -q -c a; echo a > README.md; git commit -q -am 'a version'
git switch -q main; echo main > README.md; git commit -q -am 'main version'
git merge a > /dev/null || git status -s
git merge --abort; git status -s | wc -l
Output
UU README.md 0
Run this on your computer — see “Get Started” for setup.
To resolve a conflict instead, edit the files to remove the <<<<<<<, ======= and >>>>>>> markers, git add them and run git commit.
Related
git rebase· Replay your branch's commits on top of another branch for a linear history, or clean up commits with -i before sharing.git branch· List, create, rename and delete branches, and see which branches are merged.- Merging and Resolving Conflicts · tutorial