I'm using FTP in my recent web project. And I try use git to keep a local backup of all the changes on the FTP. It seems that the FTP server failed to support MFMT command (or some other thing I got wrong), the downloaded files do not preserve their timestamps.
When I do a git diff with the newly downloaded files, Git marks every files as changed.
Is there anyway I can tell Git to commit based on the diff result instead of the timestamp?
NO, Git simply does not store such (meta-)information, unless you use third-party tools like metastore or git-cache-meta. The only timestamp that get stored is the time a patch/change was created (author time), and the time the commit was created (committer time).
Use Git update-index to ignore changes To resume tracking, run the git update-index command with the --no-skip-worktree flag. Or, you can temporarily stop tracking a file and have Git ignore changes to the file by using the git update-index command with the assume-unchanged flag.
These changes mean that metadata about your file changed, however the content of your file did not. If you're working in a group, this may start to intefere with pushes or just add noise to your commits.
gitignore should list the names or name-patterns of files that will be found in work-trees when working with your project, but that should not be committed to the project. In other words, it's not OS-specific, it's project-specific.
Git only sees the content of the file to determine if it is changed. It is not concerned with the timestamp if the content is the same. Make sure there really isn't any change in the content, including line endings. Try setting proper autocrlf
config based on your OS if so.
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