03 Git 对象的理解

1957阅读 0评论2012-08-25 Garfield_Trump
分类:项目管理

1,了解git对象

  1. git log --pretty=raw --graph
  2. git cat-file -t "commit hash code"
  3. git cat-file -t "tree hash code"
  4. git cat-file -t "parent hash code"
  5. commit : 本次提交的唯一标识
  6. tree: 本次提交所对应的目录树
  7. parent: 本次提交的父提交

  8. git cat-file -p "commit hash code"
  9. git cat-file -p "tree hash code"
  10. f58da9 的类型是tree,所以其内容是列出本次commit对应的目录的内容 welcome.txt

  11. git cat-file -t "blob hash code"
  12. git cat-file -p "blob hash code"
  13. fd3c069 的类型是blob,是commit对应的文件,所以其内容就是文件本身的内容。

  14. git cat-file -p "parent hash code"
  15. 07721c 的类型是parent,即本次提交的上一次提交,所以看到的内容是上一次的提交。

2,深入了解 HEAD、master、git对象的关系
先看当前库中所有提交的关系如下图:

  1. 查看当前branch信息
  2. git branch

  3. git log HEAD
  4. git log master
  5. git log refs/heads/master

  6. cat .git/HEAD
  7. cat .git/refs/heads/master
  8. git cat-file -t "hash code of .git/refs/heads/master output"
  9. git cat-file -p "hash code of .git/refs/heads/master output"
  10. git rev-parse HEAD
  11. git rev-parse refs/heads/master
  12. git rev-parse master
呵呵,这里就自己去看图理解啦!

HEAD 是master的一个引用,指向refs/heads/master文件;
master 是最后一次提交;


上一篇:02 Git 暂存区的理解
下一篇:VMware 缩减虚拟磁盘文件大小