Home  >  Q&A  >  body text

windows平台git每次都会出现莫名其妙的许多changs,但是对比后又没有发现不同

我在bitbucket.org上有一个git库,方便我在单位和家里的机子上同步代码,但是每次从服务器上拉下来代码都会出现很多修改,重新clone也不行,用文件对比工具查看也没有看到修改。

怀疑是line endings的问题,把git重新安装了下,选择了checkout what,commit what那个选项,仍然不行,求解释求指导,谢谢 o(╯□╰)o

-----补充----

现在确定是line endings问题了,下面是commit的log,一满屏,都是这样的。怎么设置?需要重新安装还是修改配置?
另外这个问题是什么原因导致的呢?我两台机子上设置的一样呀,难道是服务器给转了?

The file will have its original line endings in your working directory.
warning: CRLF will be replaced by LF in src/Presentation.Seedwork/Resources/Mess
ages.Designer.cs.
The file will have its original line endings in your working directory.
37 files changed, 3234 insertions(+), 3234 deletions(-)

大家讲道理大家讲道理2733 days ago899

reply all(3)I'll reply

  • phpcn_u1582

    phpcn_u15822017-04-25 09:05:49

    Try setting it up on your local repo

    git config core.filemode false
    git config core.eol lf
    

    reply
    0
  • 我想大声告诉你

    我想大声告诉你2017-04-25 09:05:49

    Based on your description, it seems that your company and your home use different operating systems, so the difference in newline characters will make Git think that the content of the file has changed. This can be set up to let Git intelligently convert it for you:

    1. In Windows systems, the option core.autocrlftrue should be set when installing Git, which is the one shown in the picture below:

    2. Under Linux/Unix/Mac systems, generally speaking, just keep the default settings (there is no installation interface to choose from). Of course you can edit it manually ~/.gitconfigcore.autocrlfinput, like the settings on my machine:

    The final result of the above two settings is that Git will always automatically convert line breaks to LF,并且在 Windows 下 checkout 回来时自动帮你转换为 CRLF when submitting, so as to adapt to the editor under Windows.

    If you have made the above settings and still encounter the problem described in the question, then don’t think about it, it must be that other members of your team have not made the settings for the above two points (most likely they are using Windows) ), you can check them one by one.

    In addition, another setting when installing Windows Git is also confusing. It is recommended to choose the one shown below:

    Choose this option, which requires the least amount of configuration, and the compatibility between CLI and Linux is relatively high. The only flaw is that commands with the same name as Linux in Windows CLI will be overwritten by the Linux version, such as find and the like. In my opinion, the Windows CLI is rubbish anyway, and it doesn't matter if it is covered.

    reply
    0
  • PHP中文网

    PHP中文网2017-04-25 09:05:49

    Being able to compare line endings is the basic ability of any comparison tool

    reply
    0
  • Cancelreply