Reputation: 1807
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.
Upvotes: 23
Views: 17465
Reputation: 1329082
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.
Upvotes: 41
Reputation: 1436
If you are using WP as a submodule, that means you probably have the need to access the history inside that submodule. That means you need this pack file.
Git packs data in pack files. This is for effenciency and disk space saving purpose. See Git internal - Packfiles . If you wonder what is in the packfile, you can use the git verify-pack command. Used with the -v option, you might find out that a huge file has been put in your repository.
If for some reasons you want to 'clean' the submodule, I would then suggest your to read Why is my repo so big ?
If you do not want the full history in the submodule, you can try to clone it with the -depth option (see git submodule command), so that it is a shallow clone with a history truncated. This might decrease the size of the pack folder.
1) clone the main repo without the recurse option
2) inside the main repo, initialize the submodule using the git submodule command with the -depth option
Upvotes: -1