Git checkout does not throw away my changes
I am using git 1.7.1 on Windows XP with cygwin. The issue can be best illustrated by example:
$ 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 shows that there are some changes in the listed files but I cannot get rid of the changes- the file is still there. It seems that it only happens to files where there are no changes other than whitespace (because git diff -w does not output anything.
I think this might be caused by git's crlf settings, but I am not sure about it.
Any checkout file which result in a content (in the "working directory", i.e. directly in your disk as a file) different from the index mean some kind of "automatic content transformation" just took place.
- either an autocrlf setting (which I recommend to set to false)
- or a filter driver (with smudge/clean scripts)
精彩评论