Pull updates with git after cloned with –depth 1

Issue

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?

Solution

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.

Answered By – mgarciaisaia

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published