Faster Git Clones
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.
Written by Max Howell
Related protips
9 Responses

Nice! Thanks for sharing!

Thats a sweet tip

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

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.
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.

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.

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

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.
I assure you I have been using this since Git 1.4 or so.