Home > Software design >  Git shows unmodified files as modified
Git shows unmodified files as modified

Time:03-19

Setup

  • git version 2.32.0.windows.1
  • TortoiseGit 2.13.0.1
  • git config -l
  • Diff Tool: BeyondCompare
    http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
    http.sslbackend=openssl
    diff.astextplain.textconv=astextplain
    filter.lfs.clean=git-lfs clean -- %f
    filter.lfs.smudge=git-lfs smudge -- %f
    filter.lfs.process=git-lfs filter-process
    filter.lfs.required=true
    credential.helper=manager-core
    core.autocrlf=true
    core.fscache=true
    core.symlinks=false
    core.editor="C:\\Program Files (x86)\\Notepad  \\notepad  .exe" -multiInst -notabbar -nosession -noPlugin
    pull.rebase=false
    credential.https://dev.azure.com.usehttppath=true
    init.defaultbranch=master
    user.email=***
    user.name=***
    core.quotepath=false
    core.commitgraph=true
    core.longpaths=true
    receive.advertisepushoptions=true
    gc.writecommitgraph=true
    credential.helper=manager-core
    filter.lfs.process=git-lfs filter-process
    filter.lfs.required=true
    filter.lfs.clean=git-lfs clean -- %f
    filter.lfs.smudge=git-lfs smudge -- %f
    submodul.recurse=true
    core.bare=false
    core.repositoryformatversion=0
    core.filemode=false
    core.symlinks=false
    core.ignorecase=true
    core.logallrefupdates=true
    remote.origin.url=***
    remote.origin.fetch= refs/heads/*:refs/remotes/origin/*
    branch.master.remote=origin
    branch.master.merge=refs/heads/master

History

We switched from SVN to GIT and after that we converted the encoding from Windows1252 to UTF8. At this point everything looks fine, but I wanted to mention anyway. These changes are committed successfully.

Error

git status and TortoiseGit both list a lot of files (maybe all) as modified, but these files are binary identical...
git diff shows all lines as deleted and the exact same lines as added.
git diff -w only list non text files (jar).
The diff seems a bit strange to me, since all files are exact the same (I compared the hex data).
Since everything is modified, I cannot pull. My co-worker sometimes have similar problems.

EDIT: I also noticed that the error only occurs after the commit in which we added .gitattributes. This contains something like this:

*.c     text diff=c
*.cpp   text diff=cpp
*.hpp   text diff=cpp
*.h     text diff=c

If I comment out those lines all modifications are gone. If I comment those lines back in the modifications are still gone.

Attempts

  • git reset --hard
  • git stash
  • revert via TortoiseGit

after these tries git status and TortoiseGit still list these files as modified...
If I commit those files, this strange behaviour is gone, but may reappear in different branches for example.
The only thing that changes is the last modified timestamp of the file. The timestamp changes to the actual time.

Question

Why are all these files listed as modified? Is there a setting which I'm missing?

CodePudding user response:

As @torek stated out in the comments: the .gitattribute text settings caused the problem. We committed those modified files and everything went well after that.

  • Related