无法重置为git中的干净工作目录

Jas*_*rat 4 git windows-7

由于某种原因,我无法重置我的git工作目录中的一个特定文件!

开始:

我做了一个git reset - 现在,

 $ git reset --hard
 HEAD is now at 97b3164 Added clojure jars for personal tracking and also set clo
 jure classpath in jaskirat.el
Run Code Online (Sandbox Code Playgroud)

硬重置后:

 $ git status
 # On branch master
 # Changed but not updated:
 #   (use "git add <file>..." to update what will be committed)
 #   (use "git checkout -- <file>..." to discard changes in working directory)
 #
 #       modified:   elpa-to-submit/color-theme.el
 #
 no changes added to commit (use "git add" and/or "git commit -a")  
Run Code Online (Sandbox Code Playgroud)

我也试过git checkout - elpa-to-submit/color-theme.el但似乎没有什么能让我回到一个"干净"的未分级工作目录!:-S

注意:我的linux桌面上也有来自github的这个repo的克隆,我在桌面上看不到这样的问题

art*_*non 8

根据您的git diff反馈,这似乎是一个EOL问题.Windows使用\r\n,而Linux使用\n.见core.eol,core.safecrlf并且core.autocrlf在设置git-config(1).

  • 非常感谢!我将autocrlf设置为false并执行checkout - *然后将autocrlf设置为true并执行checkout - *我不知道是什么原因引起了这一点,但我现在有一个干净的目录. (2认同)
  • 您必须在CRLF编辑器中打开`elpa-to-submit/color-theme.el`并点击"保存".编辑器将所有行结尾转换为`\ r \n`,Git尊重您明确更改行结尾并且没有将它们踩出来的事实.为什么不"自动"转换行结尾?因为它无法区分文本和二进制文件:当用`\n`替换`\ r \n`时,二进制文件将被破坏. (2认同)