Git学习之Git对象

来源:互联网 发布:蓝牙怎么分享软件 编辑:程序博客网 时间:2024/05/21 15:00

=============================
Git对象
=============================
 (1) 查看日志
  $ git log -l --pretty=raw
 (2) 查看Git 对象的ID的类型
  $ git cat-file -t 2d392
 (3) 查看Git 对象的内容
  $ git cat-file -p 2d392
 (4) 查看对象在对象库中的位置
  $ for id in abe84366 b52c32e 6ed5ee6;
  do \ ls .git/objects/${id:0:2}/${id:2}*;
  done
 (5) 查看跟踪链
  git log --pretty=raw --graph e695606
 (6) 查看当前分支
  git branch
 (7) 显示引用对应的提交ID
  git rev-parse master

==============================
SHA1 哈希值
==============================
 (1) 查看HEAD对应的提交的内容
  git cat-file commit HEAD
 (2) 查看提交信息中包含的字符数
  git cat-file commit HEAD | wc -c
 (3) 在提交信息的前面加上内容 commit 234<null>(<null>为空字符)
  执行哈希算法
  ${printf "commit 234\000"; git cat-file commit HEAD} | shalsum
 (4) 查看版本库中文件的内容
  git cat-file blob HEAD:1.txt
 (5) 文件包含的字节数(大小)
  git cat-file blob HEAD:1.txt | wc -c

 

0 0