Git checkout不会丢弃我的更改

时间:2010-08-24 20:45:08

标签: git

我在Windows XP上使用git 1.7.1和cygwin。 这个问题可以通过例子得到最好的说明:

$ 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:   system/application/config/email.php
#       modified:   system/application/config/upload.php
#       modified:   system/application/views/frontend/business_subscription/start_subscription.php
#
no changes added to commit (use "git add" and/or "git commit -a")

$ git checkout system/application/config/email.php

$ 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:   system/application/config/email.php
#       modified:   system/application/config/upload.php
#       modified:   system/application/views/frontend/business_subscription/start_subscription.php
#
no changes added to commit (use "git add" and/or "git commit -a")

$ git diff -w

Git显示列出的文件中有一些更改,但我无法删除更改 - 文件仍然存在。 它似乎只发生在除了空格之外没有任何变化的文件中(因为git diff -w不输出任何内容。

我认为可能是由git的crlf设置引起的,但我不确定。

1 个答案:

答案 0 :(得分:4)

导致内容(在“工作目录”中,即直接在磁盘中作为文件)的任何结帐文件与索引不同意味着发生了某种“自动内容转换”。