Git: Explore objects remotely

I am doing some extended use of Git, requesting objects to make test runs of my code optimized, so bear with me if the following sounds are very far from what most people do with Git.

I want to do something like git cat-file -p [...] , except for objects on the remote computer, without getting them. those. I want to say: "On remote origin , show me commit A , in particular, tell me what its tree identifier is, and then show me the contents of the tree (list of blocks and subtrees.)" I donโ€™t know you need to get the actual contents of the files , only the information above.

I know that I can just take the commit from the remote to the local repo and use git cat-file on it, but then it will include a selection of all the commit parents from the remote, which can take a lot of time. I need this to be fast because it was done in a program that has to run hundreds of times a day in many different repositories.

Is there a way to do this without choosing a commit?

+6
source share
1 answer

I assume that you have already confirmed that git fetch --depth=... does not do what you want.

If you have ssh/scp access to the remote computer, you can simply get a separate file for this commit (if the commit is a1b2c3d4 hash, it is stored inside the objects/a1/b2c3d4 ). Put it in local .git/objects under the same directory / name. Then use local git cat-file , as usual. From its output, you can analyze the hash of the tree and continue from there, receiving separate object files until completion. git cat-file does not care about any lost bits, if you have a hash for which the file exists, it will happily list its contents.

To avoid problems in your "real" local repository, you can do this in an empty repository, i.e. you just created using git init tmprepos or something else. It doesnโ€™t hurt that there is nothing else there.

EDIT: git stores some objects inside pack files. See https://git-scm.com/book/en/v1/Git-Internals-Transfer-Protocols for instructions on how to get to them.

+1
source

Source: https://habr.com/ru/post/1015304/