Home > Software design >  Can git detect when a file's timestamp but not its contents has changed?
Can git detect when a file's timestamp but not its contents has changed?

Time:05-13

Is there a way in git to show me a list of files that have updated timestamps but no change in their contents?

Every now and then I accidentally hit "Save" in my editor on a file that I'm just viewing. When I run "git status", that file is not displayed, which makes sense since the contents haven't changed. The problem is that the Makefile believes that the file has changed, and so a full rebuild is triggered.

What I would like to be able to do is run a command that detects that a file's timestamp has changed since the last checkout, and then somehow reset that timestamp to original value.

CodePudding user response:

That has nothing to do with git, it's between you, your editor and your project setup (your makefile). Modern editors like VS Code won't actually save files that don't have changes.

That said, git intentionally doesn't use dates for anything. Linus famously went on (many) long tirades calling people who asked for file time support stupid and wrong. So you're barking up such a wrong tree, it's not even a tree anymore.

  • Related