Adding stable to a blobless clone

We regularly sync various git repos from upstream to our company speicfic Linux repository. However, sometimes when working on a development machine, I need a branch from stable that we have not synced yet. If I did a blobless clone from our repository, doing a fetch from stable is going to pull over lots of blobs that I do not need.

Instead, I want to fetch just a specific tag. I can do this by adding the tag to the fetch command, and it will pull over only those blobs

For example, 6.12.1 is the most recent stable as of the time of this writing. I cloned our repo using

time git clone   --filter=blob:none  --no-checkout    git@gitlab.com:$COMPANY/linux/linux.git
linux.git
Cloning into 'linux'...
remote: Enumerating objects: 7897467, done.
remote: Counting objects: 100% (7897467/7897467), done.
remote: Compressing objects: 100% (1588677/1588677), done.
remote: Total 7897467 (delta 6255066), reused 7896568 (delta 6254179), pack-reused 0 (from 0)
Receiving objects: 100% (7897467/7897467), 1.34 GiB | 21.69 MiB/s, done.
Resolving deltas: 100% (6255066/6255066), done.

real	1m54.141s
user	2m35.017s
sys	1m32.279s

git tag --list  | grep v6.12

v6.12
v6.12-rc1
v6.12-rc2
v6.12-rc3
v6.12-rc4
v6.12-rc5
v6.12-rc6
v6.12-rc7

And found that we did not have the 6.12.1 tag yet. So…

git remote add stable https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
time git fetch stable v6.12.1

This is what gets pulled over. It takes a little time, but that is to be expected:

Receiving objects: 100% (54243/54243), 415.91 MiB | 7.64 MiB/s, done.
Resolving deltas: 100% (8884/8884), done.
Resolving deltas: 100% (1724442/1724442), completed with 68857 local objects.

If I go to another machine with a clean git repo and count the files:

find . -print | wc -l
90556

1724442 Blobs feels high. The Linux Kernel, as it is a big chunk of code. I suspect we are getting more than just the files required for the v6.12.1 tag

If I fetched without the –tags option would have gotten the reference that the tag points to, but not the tag.


$ time git fetch stable v6.12.1
remote: Enumerating objects: 19, done.
remote: Counting objects: 100% (9/9), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 19 (delta 7), reused 7 (delta 7), pack-reused 10
remote: Enumerating objects: 1, done.
remote: Counting objects: 100% (1/1), done.
remote: Total 1 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
Receiving objects: 100% (1/1), 17.94 KiB | 17.94 MiB/s, done.
remote: Enumerating objects: 1, done.
remote: Counting objects: 100% (1/1), done.
remote: Total 1 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
Receiving objects: 100% (1/1), 20.47 KiB | 20.47 MiB/s, done.
Unpacking objects: 100% (19/19), 27.23 KiB | 8.00 KiB/s, done.
From https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux
 * tag                         v6.12.1    -> FETCH_HEAD

real	2m34.559s
user	2m27.936s
sys	0m1.391s

19 Objects came over…not quite sure what they were.

One thing that did not come over was the tag itself. However, I can check out the associated reference using:

git checkout FETCH_HEAD

This is where you pay the priced for the blobless checkout: It fetches all the blobs it needs for this branch:

time git checkout FETCH_HEAD
remote: Enumerating objects: 86108, done.
remote: Counting objects: 100% (86108/86108), done.
remote: Compressing objects: 100% (81761/81761), done.
remote: Total 86108 (delta 4618), reused 28829 (delta 3950), pack-reused 0 (from 0)
Receiving objects: 100% (86108/86108), 251.39 MiB | 9.82 MiB/s, done.
Resolving deltas: 100% (4618/4618), done.
Updating files: 100% (86680/86680), done.
Note: switching to 'FETCH_HEAD'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detached Head to false

HEAD is now at d390303b28da Linux 6.12.1

real	1m3.333s
user	0m23.439s
sys	0m4.452s

I can now save this as a branch. Yeah, I don’t use switch…too many years doing it this way”

git checkout -b defconfig

This is faster approach than checking out the full main repository plus fetching and syncing the stable trees. The over all time was ~5 1/2 minutes. There is obviously a heavier cognative load when adding the additional switches, and there will be time consequences if I need to do additional git operations.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.