Search code examples
gitgit-diff

Unable to reset files in Git


My quetsion is probably quite similar to this one: Git status shows files as changed even though contents are the same. Although my issue is, that the files in the working directory are exactly the same. I've already done those checks:

git checkout-index <file> --temp
hexdump <tempfile>
hexdump <file>

Both are exactly the same. I also tried this one from an answer to the question above:

git show HEAD:<file>|md5sum
md5sum <file>

They are also exactly the same hashes.

I also tried to undo the changes in multiple ways:

git reset --hard
git checkout -- <file>
git checkout HEAD <file>

But nothing helped. The file is still shown in the git status output as modified. I even deleted the file and copied it over from another folder, where the same repo was cloned. Still no success.

What's even more confusing: The direcrtory is only used for a deployed system. The repo was cloned just minuntes before, and all the sudden, without even touching that specific file in any way, it showed up as changed. I am therefore no longer able to perform a git pull on this directory, as it is telling me, that I have unstaged changes.

Is there any special trick, I can force Git to see the file as unchanged?

P.S. I am very new to Git, just migrated a week ago from SVN. Even though I worked with Git on some projects before, I don't know all the commands, yet.


Solution

  • It turns out, that removing the .gitattributes file with the following content caused the issue:

    *.css       eol=lf
    

    But it still makes no sense at all, as none of the files have been touched. So the issue is not really solved, but removing the .gitattributes file will at least show the correct status again.