I've read a number of articles and answers here, but they weren't helpful.
I know that git uses mtime
and ctime
do detect that file was changed without reading it, that makes sense, but:
- Running lstat on each file in my repo takes 79 seconds, but git does that in less than a second
- How does it detect added or removed files without scanning the whole directory tree?
I tried looking into sources of diff-index but they seem to be quite complicated.
Please note that it's not a duplicate of How does git detect that a file has been modified?. I get that git uses mtime
and ctime
. I wonder how git can get them so fast. Or may be git doesn't compute them each time you run git diff
? That's the point of this question.