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?