4

いくつかのファイルをコミットせずに、ローカルで変更しました。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.autocrlftrueに設定しました
  • .gitattributesの行のファイルがあります*.cs text

これで十分ではないですか?

4

1 に答える 1

4

core.autocrlfがfalseでしたが、最近trueに変更され、.netにgitattributesの変更も適用されました。その後、多くのリポジトリでプルしようとすると、存在しない変更の報告を受け取り始め、ロールバックもできなくなりました。結局、私はcoreに戻りました。autocrlfはfalseです

于 2012-04-04T19:51:30.660 に答える