git checkout - 双破折号某些文件未重置所选文件

时间:2016-09-06 23:04:31

标签: git

让我们看一下分阶段和/或修改过的文件:

$git status

On branch master
Your branch is up-to-date with 'origin/master'.
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:   .gitattributes
    modified:   .gitignore

no changes added to commit (use "git add" and/or "git commit -a")

让我们尝试回滚更改:首先从.gitattributes开始:

15:52:22/ $git checkout -- .gitattributes
15:52:40/$git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:

    modified:   .gitattributes
    modified:   .gitignore

1 个答案:

答案 0 :(得分:0)

原因是从基于Windows CRLF的文件拉到* Nix(macos)。 CRLF正在自动转换为LF - 但这会导致文件“编辑”。 git checkout 会导致同一更新发生。

我现在必须弄清楚如何避免CRLF问题:但无论如何问题都不在于checkout --