为什么git会为具有不同名称和位置的文件分配相同的哈希值?

app*_*ppu 1 git git-hash

为什么git SHA-1为具有不同名称和不同位置的文件分配相同的内容虽然内容相同?

100644 43efcd84207788e5289ee23a9ce95d9f43b13d9a 0 dir1/dir1_d2/dir1_d2_f1.txt 100644 43efcd84207788e5289ee23a9ce95d9f43b13d9a 0 test.txt

显示文件内容:

$ git cat-file -p 43efcd84207788e5289ee23a9ce95d9f43b13d9a Line 1

谢谢

zig*_*arn 6

因为内容是一样的!

Git跟踪blob对象中的内容.
使用树对象通过git解析路径.

你可以阅读Pro Git - Git Internals - Git Objects来了解git如何存储数据.