Pull updates with git after cloned with --depth 1

Git

Git Problem Overview


This morning I made a shallow clone of the Linux sources

git clone --depth 1 https://github.com/torvalds/linux.git

which resulted in a linux folder of 851Mb.

Now I would like to pull the latest changes, but

git pull

starts a seemly huge download. After 60Mb I'm at 3% which extrapolates to 2Gb. However, the 5 commits since my clone change only a bunch of lines.

Am I doing something wrong? What are the 2Gb that git tries to download?

Git Solutions


Solution 1 - Git

I think you can use --depth 1 in git pull too, so it gets just what's needed for the newest commit in the repository.

I don't know if the default behaviour is to pull everything missing, because my git help pull shows this option:

git pull --unshallow

or

git fetch  --unshallow

> --unshallow Convert a shallow repository to a complete one, removing all the limitations imposed by shallow repositories.

I'm running git version 1.8.5.2 (Apple Git-48), and maybe this is some sort-of-new behaviour, and changing a bit between versions.

Solution 2 - Git

Could any of the new commits be merge-commits pointing to commits not present in your tree? Perhaps --depth 1000 would work better and still be small enough.

Solution 3 - Git

Just use

git pull --depth=50

or specify the depth you would like to download. That should be fine.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionmatecView Question on Stackoverflow
Solution 1 - GitmgarciaisaiaView Answer on Stackoverflow
Solution 2 - GitAndreas WederbrandView Answer on Stackoverflow
Solution 3 - GitDavid WongView Answer on Stackoverflow