我在本地对几个文件进行了更改,但没有提交它们。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.cs
#
no changes added to commit (use "git add" and/or "git commit -a")
我想放弃对这些文件的更改。我尝试按照说明进行操作:
>> git checkout -- .\source\Octopus.Tentacle\Integration\PowerShell\IPowerShell.cs
该命令没有输出。现在我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 diff <file>
似乎认为整个文件已经改变,即使它没有:
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
我如何说服 git 我真的,真的没有更改文件并且不想提交它?
编辑:以下命令对这些修改也没有影响:
git checkout -- .
git checkout -f
git reset --soft
git reset --hard
编辑 2:恢复到旧版本,存储我的更改,然后清除存储最终工作。似乎我的行尾有冲突,但我不知道为什么:
- 我已经
core.autocrlf
设置为真 - 我有一个
.gitattributes
文件与该行*.cs text
这还不够吗?