How do I unpack a single git object?

前端 未结 1 994
南方客
南方客 2021-01-12 11:10

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

相关标签:
1条回答
  • 2021-01-12 11:54

    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

    0 讨论(0)
提交回复
热议问题