ILD

git merge
作者:Herbert Yuan 邮箱:yuanjp@hust.edu.cn
发布时间:2018-5-21 站点:Inside Linux Development

git merge,将两个或多个开发历史合并。


语法:

1
2
3
4
5
6
git merge [-n] [--stat] [--no-commit] [--squash] [--[no-]edit]
    [-s <strategy>] [-X <strategy-option>] [-S[<keyid>]]
    [--[no-]allow-unrelated-histories]
    [--[no-]rerere-autoupdate] [-m <msg>] [<commit>…]
git merge --abort
git merge --continue


描述

从命名commit合并改变到当前分支。从分差的地方开始合并。合并后产生一个commit,该commit有两个parent,tree是两个分支的合并,合并的方式是将分差之后的改变replay到当前分支。


选项:

--commit

--no-commit

是否commit。不commit的话一般用来测试。


--ff

如果可以fast-forward,则不产生commit消息,直接更新branch pointer


--squash

--no-squash

根据合并结果产生工作区和索引,但是不产生commit记录,也不更新HEAD。因此用户可以在下次自行提交merge后的结果。


--abort

丢弃当前有冲突的合并,并试图重构合并之前的状态。


--continue

如果由于冲突停止了,可以通过该选项继续。


如果发生冲突,可手动编辑冲突后的文件,然后再次git add 并commit,或者执行git merge --continue,这个命令会检查之前是否有冲突。

Copyright © linuxdev.cc 2017-2024. Some Rights Reserved.