2016-09-30 2 views
2

同じ違いはありません[操作]

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" 

結果:差は私の期待はGitは、ファイルの違いを見つけることができるであるgitののGit:ファイルのタイムスタンプとサイズが

によって発見されます。 なぜ、どのように知りたいですか?

PS: 1.ステップ4.1では、4.2がrespoのフォルダで動作し、gitがファイルの変更を検出する可能性があります。 タイムスタンプが未来の日付を設定する2.Ifは、Gitはまた、実行できるだけでなく

[サンプルコマンド]

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 

[LOG]

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 
+0

Gitに何か問題があるとは思わない。おそらく、あなたが戻ってコピーした 'a.txt'は、追跡されていないファイルとしてそこにあります。したがって、変更セットには表示されません。 untrackedファイルを探してください、あなたはそこにそれを見るべきです。 –

+0

実際にはステップ4の後にa.txtはすでに追跡中です – 2000

+1

実行しているコマンドを正確に表示してください。 –

答えて

0

Gitがアクセスするのではなく、ファイルをstat()しようworktree(たとえばgit statusまたはgit diffなど)を使用してコマンドを実行するたびに、すべてのファイルの内容全体に適用されます。

そうしないと、極端にコストが高くなり、通常のケースでは起こり得ないようなケースは解決しません。

関連する問題