Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git clone bare repo without blobs

Tags:

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.)

like image 458
phi1010 Avatar asked Dec 19 '16 22:12

phi1010


People also ask

Can you clone a bare repository?

Generally, a git bare repository contains an extension of . git. In this repository you cannot commit any changes hence it cannot keep a track of the changes made in your files. But you can definitely push, pull, fetch or clone from it.

What is a shallow git clone?

Git shallow clone lets you pull down just the latest commits, not the entire repo history. So if your project has years of history, or history from thousands of commits, you can select a particular depth to pull.

What does git clone -- Bare mean?

git clone --bare origin-url : You will get all of the tags copied, local branches master (HEAD) , next , pu , and maint , no remote tracking branches. That is, all branches are copied as is, and it's set up completely independent, with no expectation of fetching again.


1 Answers

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.

like image 143
VonC Avatar answered Sep 23 '22 16:09

VonC