git 没有任何变化,但 eclipse egit 将文件标记为已更改
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8227233/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
There is nothing changed, but eclipse egit marks the file as changed
提问by Freewind
I'm using eclipse egit with github. I found something strange that I didn't change anything, but egit marked the file as "changed". See the images:
我在 github 上使用 eclipse egit。我发现一些奇怪的事情,我没有改变任何东西,但 egit 将文件标记为“已更改”。看图片:
the file "run.bat" is marked as "changed"
Compare with "file in Git index", you can see nothing is different
Compare with "file in HEAD", you can see nothing is different neither
文件“run.bat”被标记为“已更改”
与“Git 索引中的文件”相比,您可以看到没有什么不同
与“HEAD中的文件”相比,您可以看到没有什么不同
My friend uses mac and I use windows, but we all configured git as "commit unix lineend".. I also checked the lineend of my source and the HEAD, they are the same(I configured git to convert them to "\r\n" when pulling)
我朋友用的是mac,我用的是windows,但是我们都把git配置为“commit unix lineend”。 n" 拉时)
Where is wrong? Is it a bug of Egit?
哪里错了?这是Egit的错误吗?
采纳答案by Adam Dymitruk
One of the first things I've had issues with in Git.
我在 Git 中遇到问题的第一件事。
I've said this forever:
我一直这么说:
git config --system core.autocrlf false
To get rid of CR highlighting in diff and patch views, use:
要摆脱差异和补丁视图中的 CR 突出显示,请使用:
git config --system core.whitespace cr-at-eol
If you share your computers with others, replace '--system' with '--global'.
如果您与他人共享计算机,请将“--system”替换为“--global”。
回答by Mark
Eclipse Preferences / Team / Git / Configuration / User Settings
Eclipse 首选项/团队/Git/配置/用户设置
("core" section)
(“核心”部分)
key: autocrlf
value: false
The key should already exist, so just need to edit the value.
键应该已经存在,所以只需要编辑值。
If creating a new key then use core.autocrlf
.
如果创建新密钥,则使用core.autocrlf
.
回答by Axel D?rfler
As a follow up, as I just ran into the same issue, another reason for EGit detecting all files as changed is a POSIX file permission problem at least when used together with Cygwin's git.
作为跟进,因为我刚刚遇到了同样的问题,EGit 检测所有文件更改的另一个原因是 POSIX 文件权限问题,至少在与 Cygwin 的 git 一起使用时。
The following will fix that; however keep in mind that this also means that they are ignored then:
以下将解决这个问题;但是请记住,这也意味着它们会被忽略:
$ git config core.filemode false
$ git config core.filemode false
回答by Marcus
For eclipse specific issues for linefeed, you can also change the return character in Eclipse Preferences where you can change the New text file line delimiter from Windows syntax to Unix which should help.
对于换行的 Eclipse 特定问题,您还可以更改 Eclipse 首选项中的返回字符,您可以在其中将新文本文件行分隔符从 Windows 语法更改为 Unix,这应该会有所帮助。
回答by lucky8060
you can ignore whitespace differences with Eclipse settings under Compare/Patch. Preferences-->General-->Compare/Patch,you can find the "Ignore white space" in the right,and select this option.
您可以在比较/补丁下忽略 Eclipse 设置中的空白差异。Preferences-->General-->Compare/Patch,你可以在右边找到“忽略空白”,选择这个选项。
回答by Venkata Naresh Babu
I also have the same issue from the Eclipse git commit is showing this issue
我也有同样的问题来自 Eclipse git commit 显示了这个问题
once modified file and finally removed the changes from the file even though it showing the file in Un staged changessection.
一旦修改了文件并最终从文件中删除了更改,即使它在Un staged changes部分显示了文件。
Solution:
Eclipse -> Window -> Preferences -> Team -> Git -> Configuration -> User Settings (right side tab)
解决方案:
Eclipse -> Window -> Preferences -> Team -> Git -> Configuration -> User Settings(右侧选项卡)
click on Add Entry
点击添加条目
Key : core.autocrlf
Value: true
click on Ok then click on Apply -> Ok Refresh your "Git Staging tab" or check the Team -> commit option. now it will only show the exact changes only.
单击“确定”,然后单击“应用”->“确定”刷新“Git Staging 选项卡”或检查“团队”->“提交”选项。现在它只会显示确切的变化。
回答by benez
i had the same issue and nothing of the proposed solutions did work. i hat the autocrlf
feature turned off, the latest version of egit and git installed. the line endings of the repository and local files were both matching.
我遇到了同样的问题,建议的解决方案都没有奏效。我autocrlf
关闭了该功能,安装了最新版本的 egit 和 git。存储库和本地文件的行尾都匹配。
the problem was caused by an entry in the .gitattributes:
问题是由 .gitattributes 中的条目引起的:
* text=auto eol=lf
i could therefore:
因此,我可以:
- remove the attribute
- commit the changes
- 移除属性
- 提交更改
but what also did work was to go to command line and type
但也起作用的是去命令行并输入
git reset --hard
git reset --hard
and then refresh in eclipse.
然后在eclipse中刷新。
回答by Sudipta Sen
In General->Workspace. Select Text encoding UTF-8
在常规-> 工作区。选择文本编码 UTF-8