2

I have a project that depends on other projects so I use git submodule.
But my project is only interested with latest commit, I don't want all of the commits back to the beginning.

For example openssl zip is 6.6MB but cloning repo is 71.76MB.
I want only the 6.6MB but with advantage of git submodule.

Is there a way out?

CodeWizard
  • 128,036
  • 21
  • 144
  • 167
Stefano Mtangoo
  • 6,017
  • 6
  • 47
  • 93

1 Answers1

3

Yes you can do it.

There is the --depth flag which can be passed to the submodule.
The --depthflag can be used in the same way as you use it when cloning repository and you wish to clone only the latest commit.

Add the --depth option to the add and update commands of git submodule, which is then passed on to the clone command.
This is useful when the submodule(s) are huge and you're not really interested in anything but the latest commit.

git submodule add --depth 1 -- <url>
git submodule update --depth -- <url>

Full documentation can be found here.

CodeWizard
  • 128,036
  • 21
  • 144
  • 167