Git:merge的时候全部采用某一个端的文件

前言

Git:merge的时候全部采用某一个端的文件。

这个帖子原本感觉没有完全搞明白这个地方。

博客

IT老兵驿站

正文

在Git使用过程中,有的时候进行 merge,可能需要会全部采用某一端的文件,换句话说,就是完全采用本地的,或者完全采用远程的,怎么实现这个功能呢?

使用 merge 命令:

1
2
3
4
# keep remote files
git merge --strategy-option theirs
# keep local files
git merge --strategy-option ours

官网是这样写的

--strategy-option=<option>
Pass merge strategy specific option through to the merge strategy.

这里的策略选项可以参考另外一篇文章《Git:真实merge》。

—-其实上面写的是不完全对的,上面这个只是配置在某一种 merge 策略下的 option,另外一篇笔记《Git:git-merge 的用法总结》后面对这些策略和选项再做一次完整的总结。

git-pull 也有同样的功能:

1
git pull -X theirs

原理是一样的。

参考

https://stackoverflow.com/questions/6650215/how-to-keep-the-local-file-or-the-remote-file-during-merge-using-git-and-the-com
https://stackoverflow.com/questions/10697463/resolve-git-merge-conflicts-in-favor-of-their-changes-during-a-pull