@
lyf362345 会英文的就看这里。
http://git-scm.com/book/en/v2/Getting-Started-Git-Basics#Git-Has-Integrity好吧,哥顺手给你翻译了
Git Has Integrity
Git 可以保证数据完整性
Everything in Git is check-summed before it is stored and is then referred to by that checksum. This means it’s impossible to change the contents of any file or directory without Git knowing about it. This functionality is built into Git at the lowest levels and is integral to its philosophy. You can’t lose information in transit or get file corruption without Git being able to detect it.
所有git 存储的东西都是经过校验之后再存储的,然后产生的校验码可以用来作为索引。这就是说,试图修改文件或文件夹的内容而又不让git 知道是不可能的。校验这个功能是在git 的底层完成的,并且融入到git 的哲学当中。你不会在git 没有侦测到的情况下,因为传输或者获取文件的过程中而造成信息丢失。
The mechanism that Git uses for this checksumming is called a SHA-1 hash. This is a 40-character string composed of hexadecimal characters (0–9 and a–f) and calculated based on the contents of a file or directory structure in Git. A SHA-1 hash looks something like this:
Git 用于校验的是 SHA-1 哈希函数。在Git 中,基于文件或者文件夹结构内容进行计算,得出一个40个字符组成的16进制字符串。一个SHA-1 哈希字符串看上去是这样的。
24b9da6552252987aa493b52f8696cd6d3b00373
You will see these hash values all over the place in Git because it uses them so much. In fact, Git stores everything in its database not by file name but by the hash value of its contents.
你会在git 的每一处都看着这些哈希值,因为它使用得非常频繁。事实上,git吧所有东西存到数据库里面的时候使用的不是文件名而是这些存储内容的哈希值。