git告诉我我的文件已更改,但我看不到任何区别 [英] git tells me that my files are changed, but I can't see any difference

查看:719
本文介绍了git告诉我我的文件已更改,但我看不到任何区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚安装了最新的Git(1.9.5),并突然告诉我,我的工作树不干净(更改不会暂存),但我看不到任何文件中的任何更改任何diff工具(我尝试过Tortoise和Visual Studio的内置)。当我运行git status时,它说:

 没有为commit提交的更改:
(使用git add<文件> ...来更新将提交的内容)
(使用git checkout - < file>放弃工作目录中的更改)

modified:inc /i_lab_orders.asp
修改:lab_order_list.asp
修改:slib / lab_order_lib.asp



然而,Git GUI的diff工具告诉我所有的行都改变了,但是我看不出有什么区别。与git bash的差异一样。



运行 git reset --hard 根本没有帮助 - 命令执行没有任何问题,但最终我仍然有相同的更改文件。



更新:core.autocrlf为false,core.fileMode也是假。我还注意到,报告要更改的文件恰好是上次提交时提交的文件。



我在Windows上。

解决方案

欢迎来到地狱。享受您的逗留: - )



您看不到的区别在于行尾。简而言之,你告诉Git将所有行结束符转换为Windows或Unix,并且repo中有一个文件,它在repo中有不同的行尾。



当你签出文件,Git进行转换,创建一个看起来正确的本地文件。当你执行 diff 时,Git不会转换(因为磁盘上的文件必须正确,为什么它会转换已经存在于回购中的文件?),现在你可以获得解决方案:确保为每个可以 push 的开发人员正确配置Git, ,使用正确的结尾提交文件一次,并获得一个愚蠢的帽子,让任何人穿着谁创建错误行结尾的文件。



相关:


I've just installed the latest Git (1.9.5), and suddenly it tells me that my working tree is not clean (changes are not staged), but I can't see any changes in any of my files in any diff tool (I tried Tortoise and Visual Studio's built in). When I run git status, it says:

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   inc/i_lab_orders.asp
        modified:   lab_order_list.asp
        modified:   slib/lab_order_lib.asp

However, Git GUI's diff tool tells me that all lines are changed, but I can't spot any difference. Same with the git bash's diff.

Running git reset --hard doesn't help at all -- the command executes w/o any problems, but in the end I still have the same "changed" files.

UPDATE: core.autocrlf is false, core.fileMode is also false. I also noticed that the files that are reported to be changed are exactly the ones that were committed in the last commit.

I'm on Windows.

解决方案

Welcome to hell. Enjoy your stay :-)

The difference that you can't see is the line ending. In a nutshell, you have told Git to convert all line endings to Windows or Unix and there is a file in the repo which has different line endings in the repo.

When you check out the file, Git does the conversion, creating a local file which looks correct. When you do a diff, Git doesn't convert (because the file on disk must be correct and why would it convert what is already in the repo?) and now you get differences which aren't there.

Solution: Make sure that Git is configured correctly for every developer who can push, commit the file once with the correct endings and get a silly hat for anyone to wear who creates files with wrong line endings.

Related:

这篇关于git告诉我我的文件已更改,但我看不到任何区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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