Don't download the whole world on git clone
We often run “git clone” to download a remote repository. This can take a lot of time, see for instance how long it took to clone the Django project on my machine:
time git clone git@github.com:django/django.git
…
git clone git@github.com:django/django.git 27.56s user 3.42s system 58% cpu 52.835 total
In this case, I had to wait almost half a minute for the whole repository to download (I am measuring it with a handy command-line utility called “time”).
But sometimes we are interested only in the latest commit(s). Git has a useful command line argument called “depth”. It allows us to specify how many commits in the history we are interested in.
Let’s try again and download only the last commit:
time git clone git@github.com:django/django.git --depth 1
…
git clone git@github.com:django/django.git --depth 1 1.23s user 0.32s system 24% cpu 6.336 total
Now the cloning took only 1.23 seconds!
Using the “depth” argument will only download the X commits from the main branch. If we want to download commits for all branches, we can do so with an additional argument “--no-single-branch”.
Hope this helps,
Petr