Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pull updates with git after cloned with --depth 1

Tags:

git

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?

like image 289
matec Avatar asked Jun 02 '14 02:06

matec


People also ask

What does depth 1 do in git clone?

Developers should be aware that the depth 1 clone operation only pulls down one branch. If the remote repository contains other branches, they won't be able to check them out locally without a pathspec error. After a git clone depth 1 operation, attempts to checkout an alternate branch will trigger a pathspec error.

How do I pull changes from a cloned repository?

To pull down (i.e. copy) the changes merged into your fork, you can use the Terminal and the git pull command. To begin: On your local computer, navigate to your forked repo directory. Once you have changed directories to the forked repo directory, run the command git pull .

Do you need to pull after clone?

After the clone, a plain git fetch without arguments will update all the remote-tracking branches, and a git pull without arguments will in addition merge the remote master branch into the current master branch, if any (this is untrue when "--single-branch" is given; see below).

How do I pull all updates from git?

The git pull command first runs a git fetch command to check for changes. The fetch operation returns the metadata for our commits . Then, the git pull command retrieves all the changes we have made to our remote repository and changes our local files.


2 Answers

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.

like image 72
mgarciaisaia Avatar answered Oct 12 '22 03:10

mgarciaisaia


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.

like image 25
Andreas Wederbrand Avatar answered Oct 12 '22 02:10

Andreas Wederbrand