为什么Git坚持即使在“Git签出--”之后文件也被修改了?

为什么Git坚持即使在“Git签出--”之后文件也被修改了?,git,line-endings,Git,Line Endings,我在本地更改了几个文件,但没有提交它们git状态显示: >> git status # On branch feature-ravendb # Your branch is ahead of 'origin/feature-ravendb' by 1 commit. # # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (u

我在本地更改了几个文件,但没有提交它们<代码>git状态显示:

>> git status
# On branch feature-ravendb
# Your branch is ahead of 'origin/feature-ravendb' by 1 commit.
#
# 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:   source/Octopus.Tentacle/Integration/PowerShell/IPowerShell.cs
#       modified:   source/Octopus.Tentacle/Integration/PowerShell/PowerShellRunner.cs
#
no changes added to commit (use "git add" and/or "git commit -a")
该命令没有输出。现在我再次运行
git status

>> git status
# On branch feature-ravendb
# Your branch is ahead of 'origin/feature-ravendb' by 1 commit.
#
# 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:   source/Octopus.Tentacle/Integration/PowerShell/IPowerShell.cs
#       modified:   source/Octopus.Tentacle/Integration/PowerShell/PowerShellRunner.c
#
no changes added to commit (use "git add" and/or "git commit -a")
>git状态
#关于分支特征ravendb
#您的分支比“origin/feature ravendb”领先1个提交。
#
#未为提交而暂存的更改:
#(使用“git add…”更新将提交的内容)
#(使用“git签出--…”放弃工作目录中的更改)
#
#修改:source/Octopus.attracle/Integration/PowerShell/IPowerShell.cs
#修改:source/Octopus.attracle/Integration/PowerShell/PowerShellRunner.c
#
未向提交添加任何更改(使用“git add”和/或“git commit-a”)
嗯,很明显文件已经改变了。而且,
git diff
似乎认为整个文件已经更改,尽管它没有:

diff --git a/source/Octopus.Tentacle/Integration/PowerShell/IPowerShell.cs b/source/Octo
--- a/source/Octopus.Tentacle/Integration/PowerShell/IPowerShell.cs
+++ b/source/Octopus.Tentacle/Integration/PowerShell/IPowerShell.cs
@@ -1,9 +1,9 @@
-<EF><BB><BF>using System;
-
-namespace Octopus.Tentacle.Integration.PowerShell
-{
-    public interface IPowerShell
-    {
-        PowerShellExecutionResult Execute(PowerShellArguments arguments);
-    }
+<EF><BB><BF>using System;
+
+namespace Octopus.Tentacle.Integration.PowerShell
+{
+    public interface IPowerShell
+    {
+        PowerShellExecutionResult Execute(PowerShellArguments arguments);
+    }
 }
\ No newline at end of file
diff--git a/source/Octopus.attracle/Integration/PowerShell/IPowerShell.cs b/source/Octo
---a/source/Octopus.attracle/Integration/PowerShell/IPowerShell.cs
+++b/source/Octopus.attracle/Integration/PowerShell/IPowerShell.cs
@@ -1,9 +1,9 @@
-使用制度;
-
-命名空间Octopus.attracle.Integration.PowerShell
-{
-公共接口IPowerShell
-    {
-PowerShellExecutionResult执行(PowerShellArguments参数);
-    }
+使用制度;
+
+命名空间Octopus.attracle.Integration.PowerShell
+{
+公共接口IPowerShell
+    {
+PowerShellExecutionResult执行(PowerShellArguments参数);
+    }
}
\文件末尾没有换行符
我如何说服git我真的,真的没有更改文件,也不想提交它

编辑:以下命令对这些修改也没有影响:

  • git签出--.
  • git签出-f
  • git重置——软
  • git重置——硬
编辑2:恢复到旧版本,隐藏我的更改,然后清除隐藏内容最终奏效。我的行尾似乎有冲突,但我不知道为什么:

  • 我已将
    core.autocrlf
    设置为true
  • 我有一个
    .gittributes
    文件,其中有一行
    *.cs text

这还不够吗?

我有一个core.autocrlf为false,但最近更改为true,并将gittributes更改应用于.net。之后,在许多存储库中,当您尝试提取时,我开始收到关于不存在的更改的报告,并且也无法回滚。最后,我返回到core.autocrlf为false

Tried是否在路径中使用前向斜杠?刚刚尝试过,但没有任何区别。这可能是一个行尾问题:
git config core.autocrlf
为true,并且我有一个.gittributes使.cs文件成为文本。此外,它只影响这两个文件(我在其中进行了更改并还原),而不是整个回购。我只是尝试了
git checkout-f
git reset--soft
甚至
git reset--hard
,文件仍然在修改。是否有
git reset--please git甚至vss都可以做这个
选项?:)你保留了.git属性吗?不,也删除了。我认为如果你做一个干净的存储库,它可能会起作用在autocrlf和gitattributes更改后再次出现。但我没有尝试过。
diff --git a/source/Octopus.Tentacle/Integration/PowerShell/IPowerShell.cs b/source/Octo
--- a/source/Octopus.Tentacle/Integration/PowerShell/IPowerShell.cs
+++ b/source/Octopus.Tentacle/Integration/PowerShell/IPowerShell.cs
@@ -1,9 +1,9 @@
-<EF><BB><BF>using System;
-
-namespace Octopus.Tentacle.Integration.PowerShell
-{
-    public interface IPowerShell
-    {
-        PowerShellExecutionResult Execute(PowerShellArguments arguments);
-    }
+<EF><BB><BF>using System;
+
+namespace Octopus.Tentacle.Integration.PowerShell
+{
+    public interface IPowerShell
+    {
+        PowerShellExecutionResult Execute(PowerShellArguments arguments);
+    }
 }
\ No newline at end of file