Git Objects
Git中有4种类型的Object
object是根据内容的SHA1值来命名的
也即长度为40的16进制数
Every object consists of three things - a type, a size and content. The size is simply the size of the contents, the contents depend on what type of object it is
使用以下命令,可以查看object的类型
1.commit object:
对应于我们每次的commit,对应git log里的每个commit
下面命令可用来查看commit对象的内容
显示结果如下:
tree 9dba3538ed085b2758cfa56190fee72d0da5fc49
parent e9cbbda4daf535e8b58e2d34957cadf7a3baab61
author test 1254019797 +0800
committer test 1254019797 +0800
parent e9cbbda4daf535e8b58e2d34957cadf7a3baab61
author test
committer test
commit对象包含其父对象的指针parent和指向tree对象的指针
2.tree object:
它一般是目录和子目录的内容,指向一堆blob对象和其他的tree目录。
每次commit时,Git 会先计算每一个子目录的校验和,然后生成一个tree对象,tree代表了这次commit时整个项目目录的快照
可以使用命令来显示tree对象的内容
3.blob object:
它实际上就是一个文件的数据内容
可以使用命令来显示blob的内容
或者,使用show命令