.git/objects/下存放着三类对象:blob、tree、commit
可能用下面的命令浏览它们:
find .git/objects -type f
e.g.
[root@localhost temp]# find .git/objects -type f
.git/objects/01/55eb4229851634a0f03eb265b69f5a2d56f341
.git/objects/fa/49b077972391ad58037050f2a75f74e3671e92
.git/objects/4f/00b57cf5a148ba85ef4b2febae1405539e343d
.git/objects/d6/70460b4b4aece5915caf5c68d12f560a9fe3e4
.git/objects/d8/329fc1cc938780ffdd9f94e0d364e0ea74f579
.git/objects/8a/824e359ce9a58b3d3d9790b86aff663b329b2f
.git/objects/1f/7a7a472abf3dd9643fd615f6da379c4acb3e3a
.git/objects/83/baae61804e65cc73a7201a7252750c76066a30
.git/objects/6d/4cce95ccfabb8381a4db3190966d834a02590e
.git/objects/3c/4e9cd789d88d8d89c1073707c3585e41b0e614
查看各对象的类型: git cat-file -t <SHA-1>
查看各对象的内容: git cat-file -p <SHA-1>
其实通过这两条命令和.git/objects下的数据就完全可以了解版本的历史结构,不过这个过程相当的烦琐。
完成从数据库中添加内容到暂存区:git update-index --add --cacheinfo 100644 <SHA-1> test.txt
完成暂存区文件快照的更新:git update-index <filename>
完成暂存区中添加新文件:git update-index --add <newfilename>
把暂存区的文件快照写为树对象,并保存到.git/objects/目录中:git write-tree
读取.git/objects/目录下的树对象所包含的文件快照到暂存区:git read-tree <tree-SHA-1>
清空暂存区: git read-tree --empty
把树对象的文件快照作为目录读入暂存区:git read-tree --prefix=<dir-name> <tree_SHA-1>
提交树对象并加相关信息:git commit-tree <tree-SHA-1>
提交树对象并加相关信息,同时指定与上一次提交的前件连接关系:git commit-tree <tree-SHA-1> -p <commit-SHA-1>
查看当前的版本日志:git log <SHA-1> 或 git log --stat <SHA-1>,会顺着提交的连接关系显示版本历史。