Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to git clone without downloading the file objects

Tags:

git

Is it possible to download all commits but not the files themselves? I want to run bisect but download the versions from the build server instead of compiling myself.

like image 509
Bruno Martinez Avatar asked Sep 05 '25 03:09

Bruno Martinez


1 Answers

When you run git bisect you can supply --no-checkout as argument if you do not want to checkout a new working tree for each iteration.

Same goes for git clone --no-checkout to avoid a working tree based on HEAD after the clone.

You can run git bisect run my_script <arguments> having my_script do whatever you want after each checkout.

In summary:

git clone <repo> --no-checkout
git bisect --no-checkout run my_script arguments

EDIT:

As per the suggestion of @phd, since recent versions (v2.2x) of git, "partial clones" are now supported meaning you can supply a clone "filter".

https://git-scm.com/docs/partial-clone

In your case we'll use --filter=blob:none and --filter=tree:0 and only retain commit-objects, but it requires the server to have a version of git installed that understands the filter or you'll get a warning:

warning: filtering not recognized by server, ignoring

The clone command you'll want to use:

git clone <repo> --filter=blob:none --filter=tree:0 --no-checkout
like image 103
zrrbite Avatar answered Sep 07 '25 23:09

zrrbite



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!