Search code examples
gitmsysgit

Why is git not showing my files as modified?


Changing a file

I modify a file on disk, run git status, says nothing changed. Run git update-index --really-refresh and the modified file shows up.

Since a couple of weeks I've had this bug several times per day, I suspect its a new git4win bug, or perhaps even related to Windows file system. I've been using git since it's inception a decade and a half ago, so it's not "I forgot X". I've had the error occur four times in the last two hours. And then I've even been on a one hour lunch break!

$ git --version
git version 2.23.0.windows.1

Bad Theory

I initially thought it might have had something to do with Windows Subsystem for Linux-git which I had separately installed. After removing that installation and cloning all my repositories again (for the Nth time) I still get this error.

Modifying an added file

git missing my modified files also applies to files that have been added already, but have been modified since. That leads me to commit+push a lot of files which I've reviewed+compiled (either in my IDE or on the cli), but their contents are not the same, and sure enough. When I run update-index --really-refresh I see that I've pushed the files that were added initially, but not the file that I modified and compiled.

What it isn't

This has nothing to do with git ignore, as this happens to already added files (see second scenario above). It is not directly related to WSL, as I've uninstalled git there. I have no strange git settings:

core.symlinks=false
core.autocrlf=true
core.fscache=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
help.format=html
rebase.autosquash=true
http.sslbackend=openssl
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
credential.helper=manager
diff.astextplain.textconv=astextplain
user.name=Jonas Bystrom
user.email=...
core.autocrlf=true
core.pager=less -F -X
core.longpaths=true
alias.ca=commit -a
alias.nb=checkout -b
alias.quicklog=log --pretty=format:"%h %cr %cn %Cgreen%s%Creset"
alias.logdiff=log -p --stat
alias.search=log --source --all -p --decorate=full -G
push.default=upstream
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
remote.origin.url=ssh://...
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master

I have no idea what to try. Any pointers of what to try are welcome!


Solution

  • The direct cause was that my files had been "assume unchanged", which you can check by

    $ git ls-files -v pom.xml
    h pom.xml
    

    That h flag means that git should ignore it when looking for modified files. Fix by:

    git update-index --no-assume-unchanged pom.xml
    

    Edit 2: I had erroneously filed a bug with IDEA community edition, while the root cause was that my corporate home directory (H:\) had a .gitconfig which contained core.ignoreStat=true. The .gitconfig I used in bash.exe/msys (C:\Users\xxx\) did not. Fix by setting core.ignoreStat=false.