IT博客汇
  • 首页
  • 精华
  • 技术
  • 设计
  • 资讯
  • 扯淡
  • 权利声明
  • 登录 注册

    git 对象(.git/objects)

    rock发表于 2015-04-14 11:05:52
    love 0

    objects为git对象存着真实的目录数据。对于objects有以下操作命令及参数:
    git cat-fle
    -t
    Instead of the content, show the object type identified by .

    -s
    Instead of the content, show the object size identified by .

    -e
    Suppress all output; instead exit with zero status if exists and is a valid object.

    -p
    Pretty-print the contents of based on its type.

    -p
    Pretty-print the contents of based on its type.


    Typically this matches the real type of but asking for a type that can trivially be
    dereferenced from the given is also permitted. An example is to ask for a "tree" with
    being a commit object that contains it, or to ask for a "blob" with being a tag
    object that points at it.

    --textconv
    Show the content as transformed by a textconv filter. In this case, has be of the form
    :, or : in order to apply the filter to the content recorded in the index at
    .

    --batch
    Print the SHA-1, type, size, and contents of each object provided on stdin. May not be combined with
    any other options or arguments.

    --batch-check
    Print the SHA-1, type, and size of each object provided on stdin. May not be combined with any other
    options or arguments.

    我们来看一次提交涉及的sha1值:
    git 对象(.git/objects) - rock - 牧笔临风
    这里涉及到三个sha1值,commit、tree和parent
    commit 保存着基础信息,包含本次提交的sha1,注释,父节点的id
    tree 保存着文件的基本信息,文件内容保存在tree中id对应的文件里
    parent 父节点信息
    文件内容通过下面命令:
    [yanqing4@localhost sample]$ git cat-file -p be0767d1b
    100644 blob 6ad9396c22bffa93eb2afd85b9af71daaccc2b2e a.txt
    获得id为:6ad9396c22bffa93eb2afd85b9af71daaccc2b2e
    再通过 git cat-file -p 6ad9396可以获得。
    文件保存在.git/objects中上面前两位红色对应objects目录索引,后38绿色位为目录名。
    [yanqing4@localhost sample]$ ls .git/objects/6a/
    d9396c22bffa93eb2afd85b9af71daaccc2b2e

    更详细的信息参考:http://git-scm.com/book/zh/ch9-2.html






沪ICP备19023445号-2号
友情链接