4

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.

4
  • 1
    Do you mean to get the .git file only?
    – ignacio
    Commented Dec 11, 2019 at 4:56
  • @ignacio Even more — only commits without trees and blobs.
    – phd
    Commented Dec 11, 2019 at 12:47
  • 1
    Food for thought and experiments: you can try to use git clone --filter=blob:none but for this you need the very latest client and the very latest server that supports Git Protocol version v2. Further reading: stackoverflow.com/a/48852630/7976758, stackoverflow.com/a/52916879/7976758, stackoverflow.com/a/57896644/7976758
    – phd
    Commented Dec 11, 2019 at 12:50
  • Also my advice is to estimate the number of commits you need to run git bisect and use git clone --depth to avoid cloning the entire repository. Combine that with --bare or --no-checkout.
    – phd
    Commented Dec 11, 2019 at 12:52

1 Answer 1

13

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
5
  • 2
    That stops git creating the files on the working dir, but clone still downloads them to .git/objects Commented Dec 11, 2019 at 3:25
  • That's what he asked for, was my interpretation. "Download all the commits but not the files". He'll have the history but not the current working tree.
    – zrrbite
    Commented Dec 11, 2019 at 5:08
  • You cannot run git bisect (or git anything) without a .git/ folder (except ofcourse the obvious ones like git init, git clone, etc)
    – zrrbite
    Commented Dec 11, 2019 at 7:55
  • @phd "only commits without trees and blobs." exactly Commented Dec 11, 2019 at 15:32
  • I updated the answer with "partial-clone" syntax for blobs and trees
    – zrrbite
    Commented Dec 12, 2019 at 8:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.