How to make msysgit
to scan files for real changes?
Currently it seems to rely on file timestamps and therefore it makes mistakes: shows no differences where there are.
I tried git update-index --refresh
and git update-index --really-refresh
. Both commands exit immediately and do not seem to perform a scan and a binary comparison of each file in the tree.
A citation from another question:
Setting
core.trustctime
tofalse
makes git ignore spurious changes to ctime, which apparently happens on some file systems. I need the opposite behavior: re-computing the file hash even when mtime hasn't changed.
First, you should try to find the root of the problem. Git's use of stat information (not only timestamp, but also size) is normally very reliable. If you are having issue with it, it most likely means you have something seriously broken on your system. Git will not be the only tool to be broken then (your backup system and your build system will most likely be, too).
You can try this (after reading the warning below):
rm -f .git/index
git reset HEAD
The rm
command will obviously discard any information in the index, that is: all stat information that Git uses internally to avoid comparing files (what you expect), and any git add
, git reset
, information about unmerged files that you may have uncommitted in your index. This will not change any committed information, on the other hand. The git reset HEAD
command will create a new index that matches HEAD
, i.e. after this command, Git considers that you don't have changes staged in the index.
Git will restore the stat information (i.e. redo the whole file comparison) at the time of git reset HEAD
, so this is a solution to tell Git "forget stat information now", to run after you break your stat information, but it is not a way to tell Git "never use stat information again".
One thing you can do is update the timestamp of all files to the current time; you can do this with find . -exec touch {} \;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With