git merge

Table of Contents

git merge reference

# Merge 'other_branch' into 'branch'.
# Current branch is always the target branch
git checkout 'branch'
git merge 'other_branch'

The three-way merge marker lines (<<<<<<<<, ========, and >>>>>>>>) are automatically generated, but they’re just meant to be read by you, not (necessarily) a program. You should delete them with your text editor once you resolve the conflict.

Resolve conflicts howto

If you have questions, please
<<<<<<< HEAD
open an issue
=======
ask your question in IRC.
>>>>>>> branch-a

Check the conflict causing commits

git log --merge --left-right -p
#           │       │         └─ --patch, generate patch(show commit messages and diffs)
#           │       └─ display '<' if the commit is left(ours), right(theirs) otherwise.
#           └─ show only commits related to the conflict

Resolve conflicts manually

Fix the conflict like this
If you have questions, please open an issue or ask in our IRC channel if it's more urgent
Stage it
$ git add guide.md

Resolve conflicts with ours or theirs

Before triggering merge
git merge -X theirs
#          └─ --strategy-option

# NOTE: Don't be confused with '-s, --strategy' option.
# If '-s theirs`, The merge simply uses all the changes from 'theirs
# and ignores all the changes from 'ours',
# while '-X theirs' mergers with the default strategy('recursive') and
# uses the changes from `theirs` only when there are conflicts.
If you are already in conflicted state
git checkout --theirs .
git add .

Continue with the resolved resulte

Case1
commit when merging
$ git commit -m "Resolved merge conflict"
Case2
rebase –continue when rebasing
$ git rebase --continue