Git:当文件时间戳和大小相同时没有区别 [操作]

Git:当文件时间戳和大小相同时没有区别 [操作],git,Git,结果:git不会发现任何差异 我的期望是git能够找到文件的差异。 我想知道为什么和如何 附言: 1.如果步骤4.1、4.2在respo的文件夹中运行,git可以找到文件更改。 2.如果时间戳设置了未来的日期,git也可以运行良好 [示例命令] [日志] Git尝试stat()文件,而不是每次使用工作树运行命令时访问每个文件的全部内容(例如Git status或Git diff) 否则的话,成本会非常高,并且无法解决任何正常情况下可能发生的任何问题。我怀疑Git是否有任何问题。最有可能的是,您复

结果:git不会发现任何差异

我的期望是git能够找到文件的差异。 我想知道为什么和如何

附言: 1.如果步骤4.1、4.2在respo的文件夹中运行,git可以找到文件更改。 2.如果时间戳设置了未来的日期,git也可以运行良好

[示例命令] [日志] Git尝试
stat()
文件,而不是每次使用工作树运行命令时访问每个文件的全部内容(例如
Git status
Git diff


否则的话,成本会非常高,并且无法解决任何正常情况下可能发生的任何问题。

我怀疑Git是否有任何问题。最有可能的是,您复制回来的
a.txt
作为未跟踪的文件存在,因此不会显示在更改集中。查找未跟踪的文件,您应该会在那里看到。请准确显示您正在运行的命令。请参见此处:git似乎正在尝试使用修改时间等来确定哪些文件已更改。我理解这是一个理论上的案例,但除非你真的想做到这一点,否则你究竟如何编辑你的文件并保持大小和时间一致?这基本上是@ChrisMaes所说的复制品,尽管你的版本有“复制演示的步骤”的优点,因此,我不会将其作为副本关闭。:-)
1. Install git on windows 7  
2. Init a respo  
3. Add a new text file name "a.txt" and commit  
4. Copy a.txt to another folder:  
   4.1 Change one word in txt file, keep the same file size  
   4.2 Change file time stamp to original  
5. Copy updated a.txt back to the git respo just created  
6. Check use command "git status" or "git diff"  
Set PATH=%PATH%;D:\Git\bin  

git init Test  
cd Test  

echo 123456 > a.txt  
D:\XXX\FILETIME.exe a.txt 09/29/2016 12:12:12  

git add .  
git commit -m "init a.txt"  

echo 654321 > a.txt  
D:\XXX\FILETIME.exe a.txt 09/29/2016 12:12:12  

git status  
git diff  
C:\>git init Test  
Initialized empty Git repository in C:/Test/.git/  

C:\>cd Test  
C:\Test>echo 123456 > a.txt  

C:\Test>D:\xxx\FILETIME.exe a.txt 09/29/2016 12:12:12  
a.txt  
Creation time ...    09/29/2016 12:12:12  
Last access time ... 09/29/2016 12:12:12  
Last write time ...  09/29/2016 12:12:12  

C:\Test>git add .  

C:\Test>git commit -m "init a.txt"  
[master (root-commit) 95f91e5] init a.txt  
1 file changed, 1 insertion(+)  
create mode 100644 a.txt  

C:\Test>echo 654321 > a.txt     

C:\Test>D:\xxx\FILETIME.exe a.txt 09/29/2016 12:12:12  
a.txt  
Creation time ...    09/29/2016 12:12:12  
Last access time ... 09/29/2016 12:12:12  
Last write time ...  09/29/2016 12:12:12  

C:\Test>git status  
On branch master  
nothing to commit, working tree clean  

C:\Test>git diff