git merge
Join two or more development histories together
git merge [-n] [--stat] [--no-commit] [--squash] [--[no-]edit]
[--no-verify] [-s <strategy>] [-X <strategy-option>] [-S[<keyid>]]
[--[no-]allow-unrelated-histories]
[--[no-]rerere-autoupdate] [-m <msg>] [-F <file>] [<commit>…]
git merge (--continue | --abort | --quit)
git merge
A---B---C topic
/
D---E---F---G master
git merge topic
A---B---C topic
/ \
D---E---F---G---H master
# record the result in a new commit along with the names of the two parent commits
git merge --abort
A---B---C topic
/
D---E---F---G master
# git merge --abort will abort the merge process and try to reconstruct the pre-merge state
git merge file
branch master
branch topic
# the file file.py both in branch master and topic
# where branch topic file.py changed and the other files changed either,
# i just want to keep file.py in branch master,so exec like this
git checktout master
git checkkout -p topic file.py
git merge params
--ff
# 快速合并,这个是默认的参数。如果合并过程出现冲突,Git会显示出冲突并等待手动解决
--ff-only
# 只有能快速合并的情况才合并。如果合并过程出现冲突,Git会自动abort此次merge
--no-ff
# 不使用快速合并。会生成一次新的提交记录,这个记录只是标识在这里进行了一次merge操作(目前还没想到应用场景)
--squash
# 压缩合并。将待合并的分支的内容压缩成一个新的提交合并进来
git merge example
A---B---C topic
/
D---E---F---G master
git checkout master
git merge topic --ff
# master D--E--F--G
\
A--B--C
git merge topic --ff-only
# master D--E--F--G
\
A--B--C
git merge topic --no-ff
# master D--E--F--G--H(new commit)
\ /
A--B--C
git merge squash
# master D--E--F--G--H(the new commit)
https://git-scm.com/docs/git-merge