Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to clone only a specified range of commits, omitting both newer and older ones to save bandwidth

Task:

To do git bisect on a repo say https://example.git , with both the ends of the bisecting range being quite older: say: za3bca (newer) and fabce1 (older).

Being on limited bandwidth, I don’t want to download all the commits up to the latest end of the range as I know for sure I don’t need them.

My approach:

So, as given on this git documentation page for git clone, I want to use both the options: --depth <depth> and --shallow-since=<date> together.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

  • I will specify the date of the older end of the range, e.g. 20220212 (yyyymmdd),
  • I’ve counted the number of commits in between the range (to say 100), and will supply some more than that as the "depth"
git clone https://example.git --shallow-since=20220212 --depth 100

But doing this gives the error: fatal: error processing shallow info: 4

>Solution :

Two things: first, your --shallow-since datespec doesn’t parse correctly. Try 2022-02-12 instead.

But that still won’t do what you want, because --depth and --shallow-since both specify how far back to go from the ref that’s being checked out (the remote’s primary branch HEAD, if not specified). You can’t use --depth to specify how far forward to go from the commit that --shallow-since finds.

If there’s a tag or a branch head at or near the end of your bisect range, you could use that as the ref to check out with the --branch option (despite the name, it accepts both branches and tags):

git clone --single-branch --shallow-since=2022-02-12 --branch=end-point https://some.repo

If there isn’t, then I don’t think there’s much you can do, other than convince someone to make such a tag or branch for you 🙂

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading