19

When I download the kernel directly as type tar.xz, and untar it, the size is around 1GB. But when I download it via git clone from here, the size is around 7GB. It shows only master branch. Why this huge difference?

Ciro Santilli OurBigBook.com
  • 18,092
  • 4
  • 117
  • 102
Israr
  • 395

1 Answers1

32

The tarball only contains the source code for the specific release of the kernel in the tarball, whereas the git repository (cloned using git clone) contains the history of the kernel going back quite a long time. Even if you only see the master branch when you initially clone it, using the default clone parameters you actually have the full repository locally: git log will show you the full history, git branch --remote will show all the available branches.

If you only want the latest commit, you can use a shallow clone which will be much smaller:

git clone --depth 1 ...

or if you want a specific date,

git clone --shallow-since=...

You can combine that with a specific branch or tag to only download that branch's tip or that tag:

git clone --depth 1 --branch v4.10-rc4 git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git linux-4.10-rc4

This produces a tree using 947MiB (and a 159MiB download).

Stephen Kitt
  • 434,908
  • git branch --remote origin/HEAD -> origin/master origin/master – Israr Jan 19 '17 at 10:04
  • i want the latest release which is 4.10.rc4.what to do with git , to get that. – Israr Jan 19 '17 at 10:06
  • This is working only downloading 60705 object . I think i got the answer.git clone --depth 1 --branch v4.10-rc4 git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git linux-4.10-rc4.Thank you all. – Israr Jan 19 '17 at 10:26
  • @StephenKitt Technically every repo each kernel developer has is it's own branch, so yes the kernel does use branches. Looking at https://git.kernel.org/ there are a few of them... with GregKH having 10 public ones just himself. What you will not see, is live branches in the primary repo (https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/) created with the git branch command, just all merged back into the default branch of those repositories. – ewanm89 Feb 07 '21 at 02:15
  • @ewanm89 yes, I was referring to the result of the clone shown in the first comment that’s left here (IIRC there were other comments which have since been deleted). – Stephen Kitt Feb 07 '21 at 06:54
  • And looking at my working repo, I see Linus’ repo has had a few branches, albeit short-lived (they’re no longer present). – Stephen Kitt Feb 07 '21 at 06:59