I'm not a Git master yet, faced a problem I can't figure out how to fix. I have a repo with my WordPress custom skeleton and I've added WordPress as a submodule from its original repo by git submodule add wp_repo_url
. When I clone my repo to local machine with:
git clone --recursive https://github.com/user/repo local_dir
it downloads the WP submodule as expected, but here's the problem - actual files are only 20.7Mb, and in .git/modules/core/objects/pack
I've got a huge 124Mb .pack file, which, I suppose, is smth like commit history / revisions of that submodule.
How can I re-add submodule or modify while cloning to prevent downloading this extra weight?
UPDATE:
With the help of @iclmam I've came up with the following setup:
if I just need a plain clean install of recent WP version, I'll change into wp directory and go the old way:
curl -L -O http://wordpress.org/latest.zip
unzip latest.zip
mv wordpress/* .
rm latest.zip
rm -rf wordpress
Not a perfect solution (I wanted to automate everything as much as possible), but it works for now.
Any advices on the original question are appreciated.
since Git 2.10+ (Q3 2016), you will be able to do a regular clone... and still benefit from shallow clone for submodules.
All you need to do is record that configuration in your .gitmodules
:
git config -f .gitmodules submodule.<name>.shallow true
Add, commit, and push: anyone cloning your repo (regular clone, full history) will get only a depth of 1 for the submodule <name>
.
See commit f6fb30a, commit abed000 and commit 37f52e9 (03 Aug 2016) by Stefan Beller (stefanbeller
).
(Merged by Junio C Hamano -- gitster
-- in commit dc7e09a, 08 Aug 2016)
submodule update
: learn --[no-]recommend-shallow
optionSometimes the history of a submodule is not considered important by the projects upstream. To make it easier for downstream users, allow a boolean field '
submodule.<name>.shallow
' in.gitmodules
, which can be used to recommend whether upstream considers the history important.This field is honored in the initial clone by default, it can be ignored by giving the
--no-recommend-shallow
option.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With