Git clone bare repo without blobs

流过昼夜 提交于 2019-12-01 09:21:13

问题


On my git repository, I use an algorithm to assign every commit one or more unique version numbers, based on branch names and tags. I want to use this mechanism with another large repository, that I would like to clone without transferring any files.

A bare clone helps me to get rid of the working copy of the blobs, but it still downloads them from the server. A shallow clone with --depth 1 skips most blobs, but also skips downloading the metadata for all commits except one.

Is there something like git fast-export --no-data which I can use on the client-side to get the graph information containing commit metadata and maybe filenames without cloning the repository from my server first? Ideally I would be able access the metadata like any other (bare, shallow) repo via git log|show|rev-parse|show-ref.

(I know git LFS and git Annex exist and can help reduce the size of some repos, but I can't use them on an existing repository without changing it.)


回答1:


Is there something like git fast-export --no-data which I can use on the client-side?

No: beside git ls-remote (which gets metadata only for the heads of the remote repo), anything else would get the full repo history.

You would need your repo managed by a Git hosting service, like GitHub, providing an API (like the commits API), in order to query metadata without data.




回答2:


Another Idea for this some time later: As of 2017, the pack-protocol now allows partial clones, and there is a --filter=blob:none available that omits all blobs -- which should be sufficient on the server-side.

Given the current server-side implementation, sadly, this doesn't work as well as one would hope:

C:\Users\phi1010>git clone https://github.com/torvalds/linux.git --filter=blob:none
Cloning into 'linux'...
warning: filtering not recognized by server, ignoring
remote: Enumerating objects: 6876195, done.
[...]

Github even announced the support of the v2 protocol and its filtering capabilities, but this neither works with -c protocol.version=2, as also stated on Do GitHub and GitLab support git clone's --filter parameter?



来源:https://stackoverflow.com/questions/41232037/git-clone-bare-repo-without-blobs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!