tags:

views:

52

answers:

3
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:   readme.txt
#       modified:   requirements.txt
#
no changes added to commit (use "git add" and/or "git commit -a")

I didn't make any changes on those files. But I'm getting this message even if I try:

git checkout -- readme.txt
git checkout -- requirements.txt

When I run:

git diff

it shows the whole file as updated. But the contents are the same.

I tried to delete them and checkout again, but it didn't work.

+2  A: 

At a guess: line endings. The files probably have different line endings to your OS, which git is handily(!) converting. You can fiddle with the core.autocrlf option to try and fix this behaviour: github has some helpful advice here.

If it is a line endings issue and it's just those files, it may be worth you normalising them to be consistent and the same as the rest of your repository. This may just be a case of committing the changes you're showing now.

Chris Smith
Thanks. But it should work after I run the checkout command, right?
pocoa
I've changed the line endings as described in the document. It didn't solve the problem.
pocoa
A: 

this sort of thing happens with line ending changes (which are not easily visible on a terminal; look at it in a binary editor) or the odd badly-written program that leaves nulls at the end of everything.

sreservoir
how many ninjas is that today? three?
sreservoir
A: 

If you can avoid any eol conversion , try:

git config --global core.autocrlf false

(my preferred configuration)

, and clone again your repo to see if the issue persist (clean status instead of "all files modified").
If your editors support other eol style and don't make any conversion, you won't be bothered again.

VonC