xr-0gw
Last Updated: February 25, 2016
·
3.163K
· mxcl
Img 0719

Faster Git Clones

git

If you don’t need the Git history when cloning (which is often the case if you are just forking to make a pull request) then you can save clone time thus:

git clone --depth 1 https://github.com/CocoaPods/Specs

For repositories with large histories, this can be a significant saving, and you are being kind to GitHub’s resources.

Say Thanks
Respond

9 Responses
Add your response

12489
Jpeg 1

Nice! Thanks for sharing!

over 1 year ago ·
12507
0d38ee92831618c24839dc002859c32f

Thats a sweet tip

over 1 year ago ·
12510
4086702a3fd23cbf7b32ce5dabfe6411

Awesome! Do you know if the same can be applied when adding a submodule?

over 1 year ago ·
12555
3b5d06b2e97e22a0dff8c93b7a93a8b8

Good tip, but it must be complete. Nothing comes without price, and in this case (from the man page):

  • ... you cannot clone or fetch from it, nor push from nor into it
  • is adequate if ... want to send in fixes as patches

The second line means -- no pull requests from a "shallow" clone repo.

over 1 year ago ·
12556
Img 0719

I've pushed from such clones many times and made pull requests from such repos. The manpage doesn't seem accurate.

Cloning from and fetching from clones is something I rarely need, and in those cases you can fetch into a separate remote and hard reset if necessary.

over 1 year ago ·
12558
Img 1613

I read the documentation a few months ago when I saw the flag somewhere and I assumed it was accurate too. I just cloned one of my repos with the flag and I was able to push and pull. Looks like the manpage needs to be updated.

over 1 year ago ·
12572
Photo on 08.01.2013 at 04.15

It causes a lot of problems, I speak from experience.

over 1 year ago ·
12926
D2561bed464920778d9eda64e8087a69

Note that this only works with git 1.9 and up, see http://stackoverflow.com/questions/6941889/is-git-clone-depth-1-shallow-clone-more-useful-than-it-makes-out

The manpage has been corrected in recent git versions, as referenced on in the question linked above.

over 1 year ago ·
12927
Img 0719

I assure you I have been using this since Git 1.4 or so.

over 1 year ago ·
Filed Under