如何解压一个git对象? [英] How do I unpack a single git object?

查看:1092
本文介绍了如何解压一个git对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

回答有关git树形对象内部格式的问题中,获取一个特定的树形对象存储在一个包中,我使用 git unpack-objects 。这似乎是矫枉过正。是的,我意识到命令如 git show --raw git ls-tree git cat-file 会将内部格式的关闭



如何让git输出一个单一的对象的内部格式 - 完整的 blob commit 标记标题 - 无论它是以宽松还是打包格式存储?

解决方案

您可以使用 git包 - 对象首先制作一个只包含这一个对象的包。



还要注意,git unpack-objects不会提取存储库中已经存在的对象,所以你可能想创建一个新的存储库。总的来说,像这样的应该是这样的:

$ $ $ code $ $ $ $ $(mktemp -d)
$ echo 5e98806c6cc246acef5f539ae191710a0c06ad3f \
| git pack-objects --stdout \
| (cd$ DIR&&&git init&&& git unpack-objects)

然后在 $ DIR / .git / objects


中查找您的解包对象

In an answer to a question about the internal format of git’s tree objects, to get to one particular tree object that was stored in a pack, I unpacked all of the objects in a repository’s packfiles using git unpack-objects. That seems like overkill. Yes, I realize that commands such git show --raw, git ls-tree, or git cat-file will get close to the internal format.

How do I make git output a single object in its internal format — complete with blob, tree, commit, or tag header — regardless of whether it is stored in loose or packed format?

解决方案

You can use git pack-objects first to make a pack with only this one object.

Note also that git unpack-objects does not extract objects which already exist in a repository, so you probably want to make a new repository. Overall something like this should work:

$ DIR=$(mktemp -d)
$ echo 5e98806c6cc246acef5f539ae191710a0c06ad3f \
   | git pack-objects --stdout \
   | ( cd "$DIR" && git init && git unpack-objects )

Then look for your unpacked object in $DIR/.git/objects

这篇关于如何解压一个git对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆