fest
fest

Reputation: 1635

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.

Upvotes: 4

Views: 2250

Answers (1)

VonC
VonC

Reputation: 1329532

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.

Upvotes: 4

Related Questions