How do you maintain the git sub-trees that come with themes?

Hello,

[thread updated – original post is below]

Themes are most frequently taken from existing ones, hosted on Github for instance. For our static sites, this lead to a git tree inside our files. We also often manage our posts & full static sites with Git. A consequence is that there is several git trees packed together.

What is the solution you find to manage them?

  • Putting all the git clone and git pull inside a README.md file?
  • Creating a shell script to execute commands like mkdir -p themes/blahblah && cd themes/blahblah/ && git pull?
  • Making a git subtree (seems tricky)?
  • Making a git submodule (seems evil)?

Thanks for the ideas!

[original post]

My site tree is managed via a git repository. I have installed external themes and I would like to be as sustainable as possible. What would you advise me to manage the themes’ git trees? I need to be able to rebuild a website from scratch if (for instance) my main computer would crash.

I can imagine:

  • Putting what to do inside a README.md file (all the git clone and so on)
  • Creating a shell script to execute commands like mkdir -p themes/blahblah && cd themes/blahblah/ && git pull or things like this.
  • Making a git subtree (seems tricky)
  • Making a git submodule (seems evil)

Actually for existing projects I used to put all that in a README file. For deployments I sometimes create a shell script (which is the case for instance for my mathematics site).

Thank you for your advice.

One thing that might work better than a shell script using git pull etc, is to keep the themes in a separate directory from the site, and then have a shell script that does an rsync from the theme directory into the themes directory of the site, excluding the .git directory, etc

This is what I do for the theme I have under development in order to get it published somewhere else (so this particular script won’t work exactly for what you’re looking for, but maybe it will point you in the right direction?)

#!/bin/sh
rsync -rv --exclude=.git --exclude=exampleSite --exclude=images /Users/mattstratton/src/castanet/ /Users/mattstratton/src/sample-castanet/themes/castanet/
rsync -rv --exclude=.git /Users/mattstratton/src/castanet/exampleSite/content/ /Users/mattstratton/src/sample-castanet/content/
rsync -rv --exclude=.git /Users/mattstratton/src/castanet/exampleSite/static/ /Users/mattstratton/src/sample-castanet/static/
rsync -rv --exclude=.git /Users/mattstratton/src/castanet/exampleSite/config.toml /Users/mattstratton/src/sample-castanet/config.toml
cd /Users/mattstratton/src/sample-castanet/
git add .
git commit -m "Update theme"
git push origin master

the last few lines probably aren’t needed for you, but for sake of completeness, I put in the whole script. the most useful part for you is probably the first line, which is what is used to sync the theme into the site.

Thank you for your answer! Another solution wouldn’t be to create a symlink?