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?
Asked
Active
Viewed 2.2k times
19

Ciro Santilli OurBigBook.com
- 18,092
- 4
- 117
- 102

Israr
- 395
-
2git clone downloads a revision control repository, that contains the history of the project, not just the latest. – ctrl-alt-delor Jan 19 '17 at 10:09
-
comes down to https://stackoverflow.com/questions/3489173/how-to-clone-git-repository-with-specific-revision-changeset + cgit – Ciro Santilli OurBigBook.com Sep 13 '18 at 08:10
1 Answers
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
-
-
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