简体   繁体   English

Git合并为仅从一个分支更改的几乎所有文件带来冲突

[英]Git merge gives conflicts for almost all files changed from only one branch

I tried to merge my local branch with our development branch, but git merge gave me conflict for almost all files that were changed in local branch. 我试图将本地分支与开发分支git merge ,但是git merge给我的冲突几乎是所有在本地分支中更改的文件。 So I had to resolve conflicts manually. 因此,我不得不手动解决冲突。 Most of those files were not changed in development. 这些文件大多数在开发中都没有更改。

For example, I get this conflict: 例如,出现以下冲突:

<<<<<<< HEAD
        render json: {:created => 'true'}.to_json, status: :created, location: @user
=======
        render json: {:created => 'true'}.to_json, status: :created, location: @user
>>>>>>> development

Or this one: 或者这个:

<<<<<<< HEAD
        # some new code
=======
>>>>>>> development

Notice that I have no new line in one of the branches. 请注意,我在分支之一中没有新行。

Someone knows why this happens, and how can I avoid it? 有人知道为什么会发生这种情况,我该如何避免呢?

This happens due to some local files has changed and not committed before you pull/checkout from the git repository. 发生这种情况是由于在从git存储库中拉出/签出之前,某些本地文件已更改并且尚未提交。

Remove these extra lines from the conflicted files and commit then. 从冲突文件中删除这些多余的行,然后提交。

What about line ending? 那行结束呢? This could be an issue, especially when your devs / you are working on different operating systems. 这可能是个问题,尤其是当您的开发人员/您正在使用不同的操作系统时。

https://help.github.com/articles/dealing-with-line-endings https://help.github.com/articles/dealing-with-line-endings

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

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