Search code examples
gitgit-clone

How to git clone a specific tag only without getting the whole repo?


I want to get linux kernel 2.6.22.19 source for cross compiling stuff for my router, but the repo is huge (3gb) if I do

git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git

and then check out that tag, the clone took forever, my bandwidth is limited.

if I run this

git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git --branch v2.6.22.19 --single-branch

the filesize recived is around 150mb, is this the correct way of doing it, what does this command likne mean ? v2.6.22.19 is a tag name right? why it can bed added after --branch ?

after cloning.

[oglop@localhost linux-stable]$ git status
# Not currently on any branch.

Solution

  • providing v2.6.22.19 is the tag name and git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git is the repository url, try this:

    git clone --depth 1 --branch v2.6.22.19 git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
    

    the --depth 1 will download only the latest commit in the branch (in this case the specified branch, default the remote's HEAD branch), this will also helps with the size issues