windows平台git每次都会出现莫名其妙的许多changs,但是对比后又没有发现不同
大家讲道理
大家讲道理 2017-04-25 09:03:49
0
3
897

我在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(-)

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(3)
phpcn_u1582

Try setting it up on your local repo

git config core.filemode false
git config core.eol lf
我想大声告诉你

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.

Ty80

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!