git:合并文件结尾的换行符上的冲突 [英] git: merge conflicts over newline at end of file

查看:796
本文介绍了git:合并文件结尾的换行符上的冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



冲突出现如下:

p>

  diff --cc httpdocs / about / faq.php 
索引0ae3963,b5eb519..0000000
- - a / httpdocs / about / faq.php
+++ b / httpdocs / about / faq.php
@@@ -212,4 -211,4 +212,8 @@@ $ _SESSION ['activePage'] ='about'
< / div><! - end wrap - >

- <?php require RESOURCE_PATH。page_elements.SLASH。footer.php; ?>
++<<<<<<< HEAD
+<?php要求RESOURCE_PATH。page_elements.SLASH。footer.php; ?>
++ =======
++<?php require RESOURCE_PATH。page_elements.SLASH。footer.php; ?>
++>>>>>>> 564e069cccfad98f818ec878a3b2526fd9430f8a

更糟;在我手动解析文件并添加冲突文件后,似乎没有任何要提交的内容(与文件末尾相关),因此当我再次执行pull操作时,我会得到完全相同的冲突。任何解决方案?

解决方案

这些差异是由于不同操作系统对结束行的不同概念造成的。 p>

Git通常可以很好地处理这些问题,通过将core.eol的配置值默认为native。但是,如果开发人员由于某种原因没有该设置,或者从Windows提交UNIX样式的文件,反之亦然,您可能会遇到这些问题。



最好找到问题的来源并在那里处理它,否则,可以尝试为core.eol(lf / crlf)设置不同的值,并查看它是否修复了此问题。如果它只发生在一个特定的路径上,而不是整个项目,那么最好为该路径定义一个gitattributes文件。

I often get conflicts while pulling (merging) in git over differences in newlines at the end of the file.

The conflict comes out looking like this:

diff --cc httpdocs/about/faq.php
index 0ae3963,b5eb519..0000000
--- a/httpdocs/about/faq.php
+++ b/httpdocs/about/faq.php
@@@ -212,4 -211,4 +212,8 @@@ $_SESSION['activePage'] = 'about'
        </div><!-- end wrap -->

 -<?php require RESOURCE_PATH."page_elements".SLASH."footer.php"; ?>
++<<<<<<< HEAD
 +<?php require RESOURCE_PATH."page_elements".SLASH."footer.php"; ?>
++=======
++<?php require RESOURCE_PATH."page_elements".SLASH."footer.php"; ?>
++>>>>>>> 564e069cccfad98f818ec878a3b2526fd9430f8a

Worse; after I manually resolve the files and add the conflicted files, there doesn't seem to be anything to commit (in relation to the end of the files), so when I do a pull again, I get the exact same conflicts. Any solutions?

解决方案

These differences are resulting form the fact that different OS's have a different idea of what ends a line.

Git usually handles those well, by defaulting the config value of core.eol to 'native'. However, if a developer does not have that setting for some reason, or committing UNIX-style files from Windows or vice versa, you might get these issues.

It is best to find the source of the issue and deal with it there, otherwise, you can try to set different values for core.eol (lf/crlf), and see if it fixes that. If it only happens on a specific path, and not the whole project, you might be better off defining a gitattributes file for that path.

这篇关于git:合并文件结尾的换行符上的冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆