Git可以忽略具有相同内容但更新时间戳的文件 [英] Can Git ignore files that has the same content but updated timestamp

查看:672
本文介绍了Git可以忽略具有相同内容但更新时间戳的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在最近的web项目中使用FTP。我尝试使用git保留FTP上所有更改的本地备份。似乎FTP服务器无法支持MFMT命令(或其他我错误的东西),下载的文件不会保留它们的时间戳。



当我做一个git与新下载的文件相比,Git会将每个文件都标记为已更改。

有什么方法可以告诉Git根据diff结果而不是时间戳吗?

解决方案

Git仅查看文件的内容以确定它是否已更改。如果内容相同,它不关心时间戳。确保 在内容中没有任何变化,包括行尾。尝试根据您的操作系统设置适当的 autocrlf 配置,如果是的话。


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?

解决方案

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.

这篇关于Git可以忽略具有相同内容但更新时间戳的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆