Is there a way to make git pull
keep depth=1
, just use the latest commit, instead of the one that git clone was made (if there is newer one)?
I I do git clone -b some_branch --depth=1 git_repo.git
It clones the repository with minimum space usage because it removes all the history.
Now if I need to update that repository again and use git pull
, it pulls the whole history.
There is a similar question here:
If try accepted answer advice and use git pull --unshallow
and then git pull --depth=1
, it looks like it does not reduce space as git clone --depth=1
does.
So the only way to really reduce repository size is to just remove repository and clone with depth=1
again?. Looks kind of clunky way to do it.
And the reason I need this is that there are repositories used when fully cloned, currently take about ~3 GB
in size. And there are like 40 environments where it is used. So in total, it uses a lot of space. With a shallow clone, it can be reduced about 5 times.
Sample:
Cloning this repository branch 12.0 git@github.com:odoo/odoo.git
, shows its size to be around 3 GB.
Cloning this repository branch 12.0 with depth=1
, shows size to be 643 MB.
Using --unshallow
on pull and then (as suggested here Converting git repository to shallow?):
git pull --depth 1
git gc --prune=all
Does not seem to shrink size as shallow clone does.