简体   繁体   English

Git合并忽略来自一个分支的冲突?

[英]Git merge ignore conflict from one branch?

I have git setup with an xcode project. 我有一个xcode项目的git设置。 Inside that project is a .storyboard file which is a very long xml file. 在该项目中是一个.storyboard文件,这是一个非常长的xml文件。

This file causes many conflicts when merging, because when updating the layout all views can get a minor change in their position or size by sometimes only 1px. 该文件在合并时会引起许多冲突,因为在更新布局时,所有视图的位置或大小可能都会有微小的变化,有时只有1px。

I have some branches in my git. 我的git中有一些分支。

When Im on my master branch and want to merge master with my Test branch i get around 30 conflicts in that particular file. 当我在我的master分支上并想将master与我的Test分支合并时,我在该特定文件中遇到了30个冲突。

Because it looks like this when there is a conflict: 因为当发生冲突时,它看起来像这样:

>>>>>> HEAD 
           <Some stuff />
======
           <Some stufff />
>>>>>> Test

Is it possible to remove all the conflicts from HEAD or the branch I merged with? 是否可以从HEAD或与之合并的分支中删除所有冲突?

When the conflict arrives there are three files created 冲突到达时,将创建三个文件

  1. File of branch in which you are says ours (master in your case) 在你的分支的文件说, ours (主你的情况)
  2. File of branch you want to merge says theirs (test in your case) 您要合并的分支文件说theirs (在您的情况下进行测试)
  3. File with all the conflicts 归档所有冲突

and you can do the followings 您可以执行以下操作

  1. Keep master branch files using git checkout --ours <file path> 使用git checkout --ours <file path>保留主分支文件- git checkout --ours <file path>
  2. Keep test branch files using git checkout --theirs <files path> 使用git checkout --theirs <files path>保留测试分支文件- git checkout --theirs <files path>
  3. Resolve the conflicts manually 手动解决冲突

You can read more about it 您可以阅读更多有关它的内容

  1. http://gitready.com/advanced/2009/02/25/keep-either-file-in-merge-conflicts.html http://gitready.com/advanced/2009/02/25/keep-either-file-in-merge-conflicts.html
  2. http://git-scm.com/docs/git-checkout http://git-scm.com/docs/git-checkout
  3. Choose Git merge strategy for specific files ("ours", "mine", "theirs") 为特定文件(“我们的”,“我的”,“他们的”)选择Git合并策略

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM