2

I have to deal with a git repo that contains some binaries.

I would be REALLY grateful if someone could explain this to me

>git clone --depth 1 -- ssh://git/foo/bar.git test_d
Cloning into 'test_d'...
remote: Counting objects: 289, done.
remote: Compressing objects: 100% (268/268), done.
remote: Total 289 (delta 111), reused 120 (delta 19)
Receiving objects: 100% (289/289), 1.95 MiB | 519 KiB/s, done.
Resolving deltas: 100% (111/111), done.

>git clone --depth 1 -b master -- ssh://git/foo/bar.git test_db
Cloning into 'test_db'...
remote: Counting objects: 5980, done.
remote: Compressing objects: 100% (1777/1777), done.
remote: Total 5980 (delta 3868), reused 5657 (delta 3660)
Receiving objects: 100% (5980/5980), 36.50 MiB | 1.10 MiB/s, done.
Resolving deltas: 100% (3868/3868), done.

>git clone -b master -- ssh://git/foo/bar.git test_b
Cloning into 'test_b'...
remote: Counting objects: 6953, done.
remote: Compressing objects: 100% (1779/1779), done.
remote: Total 6953 (delta 4419), reused 6946 (delta 4417)
Receiving objects: 100% (6953/6953), 57.25 MiB | 1.15 MiB/s, done.
Resolving deltas: 100% (4419/4419), done.

That is, why when passing -b it seems like it's changing behaviour of --depth ?

GiM
  • 460
  • 4
  • 13

3 Answers3

1

Instead of just git clone <url>

use git clone -b <branch> <url> --depth=1

See here: quickly-clone-a-large-git-repo this is my reference.

marlo
  • 6,998
  • 5
  • 28
  • 34
  • You haven't read the question, or haven't looked at an example. The problem is that when combining both --depth AND -b, git downloads (almost) WHOLE repository therefore --depth becomes totally useless. – GiM May 09 '15 at 19:20
0

hmm, I think I found solution, in related question: Partial clone with Git and Mercurial

> md test_foo
> cd test_foo
> git init
> git remote add origin ssh://git/foo/bar.git
> git config --local remote.origin.fetch +refs/heads/master:refs/remotes/origin/master
> git pull --depth 1
remote: Counting objects: 289, done.
remote: Compressing objects: 100% (268/268), done.
remote: Total 289 (delta 111), reused 120 (delta 19)
Receiving objects: 100% (289/289), 1.95 MiB | 496 KiB/s, done.
Resolving deltas: 100% (111/111), done.
From ssh://git/foo/bar.git
 * [new branch]      master     -> origin/master

but that doesn't seem like a solution ;/

Community
  • 1
  • 1
GiM
  • 460
  • 4
  • 13
0
  1. Shallow clone of repositories

    git clone --depth [number_of_commits] [url_of_remote]

  2. Clone a single branch

    git clone [url_of_remote] --branch [branch_name] --single-branch

http://www.sitepoint.com/managing-huge-repositories-with-git/

Joshua
  • 689
  • 7
  • 16