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

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/chaiyu2002/article/details/83791671

原帖收藏于IT老兵驿站,传递一个IT老兵在凋零前的光和氧。

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

正文

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

使用merge命令:

# 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》。

git-pull也有同样的功能:

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

猜你喜欢

转载自blog.csdn.net/chaiyu2002/article/details/83791671