user2879704
user2879704

Reputation:

Download or clone only a branch in git and not the entire tree

Cloning linux kernel code from Torvalds git account, the code size runs into GBs. possibly, it is downloading all branch code. is there anyway i can download only the code of a particular tag.

i can do,

git clone https://github.com/torvalds/linux
git checkout -t v3.13

but, i don't want all the trunk & branch code sitting in my local.

Upvotes: 3

Views: 2489

Answers (2)

Aminul
Aminul

Reputation: 1738

Use This Command to clone repositories:

  git clone <repo_url> --branch <tag_name> --single-branch

Use --single-branch option to only clone history leading to tip of the tag. This saves a lot of unnecessary code from being cloned.

Upvotes: 1

askb
askb

Reputation: 6768

This should do the trick:

git clone --branch v3.13 git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 

Alternatively what I generally do (as I can move freely switch between versions)

git fetch linux-next
git fetch --tags linux-next

     * [new tag]         v3.18      -> v3.18
     * [new tag]         v3.18-rc3  -> v3.18-rc3
     * [new tag]         v3.18-rc4  -> v3.18-rc4
     * [new tag]         v3.18-rc5  -> v3.18-rc5
     * [new tag]         v3.18-rc6  -> v3.18-rc6
     * [new tag]         v3.18-rc7  -> v3.18-rc7
     * [new tag]         v3.19-rc1  -> v3.19-rc1
     * [new tag]         v3.19-rc2  -> v3.19-rc2

git checkout -b my_branch  v3.18

Upvotes: 4

Related Questions