Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1821819
  • 博文数量: 317
  • 博客积分: 1557
  • 博客等级: 上尉
  • 技术积分: 1208
  • 用 户 组: 普通用户
  • 注册时间: 2008-02-26 23:38
个人简介

如果想出发,就不要等到明天!

文章分类

全部博文(317)

文章存档

2016年(1)

2015年(41)

2014年(152)

2013年(114)

2012年(4)

2011年(1)

2009年(4)

分类: 项目管理

2012-08-25 13:48:40

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 是最后一次提交;


阅读(1877) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~