----- Date:

Download a github repository and its submodules

I want a full copy of all the pelican plugins and themes, which is actually difficult to acquire with git. 1 After some fruitless hours attempting several things i found on the net, I figured out a method that works:

Once you've unpacked a .zip file or done git clone on the parent repository, there's a .gitmodules file, which links all those annoying empty directories to the URL of the repo that's supposed to fill them.

[submodule "pelican-fontawesome"]
    path = pelican-fontawesome
    url = https://github.com/kura/pelican-fontawesome.git
[submodule "pelican_youtube"]
    path = pelican_youtube
    url = https://github.com/kura/pelican_youtube.git

(From pelican-plugins/.gitmodules)

Therefore, we can use some command line magic to call git for each of these in turn:

for i in `cat .gitmodules | grep "url" | cut -f 2 -d '='` ; do git clone $i --depth=1  ; done

grep "url" filters out everything that doesn't contain the string "url"; cut returns the 2nd field of the string divided on '=', and for each of those $i we do the normal git clone.

The --depth=1 tells git to only grab the latest revision data. That might not be what is wanted but it serves me.

  1. We're on a satellite ISP connection which means restricted bandwidth and generally horrible connectivity for half each month. Many things just do not work, many others require resume retries.