Best workflow for managing themes within Bedrock with git?

I’m using Bedrock for the overall framework, and Sage as my theme (well, a modified version of course).

What I’ve done so far is make my overall Bedrock folder a git repo, to keep source managed. My challenge comes in with the Sage theme - I would like to be able to fetch upstream changes to Sage (when there are improvements) but of course that isn’t really clearly possible. One method I considered was to make a separate repo for my theme (and add the roots/sage repo as an upstream remote) allowing me to fetch the upstream changes. That would mean I need to make the theme a submodule in the bedrock repo, and I kind of hate working with submodules (plus I’m not sure what havoc it would wreak with the ansible local testing fun).

How are you all handling this? Is there something simple I’m missing? My workaround for now is to have a different local repo of the core Sage theme and just fetch upstreams and diff against what I have from “core” and see if there’s anything terribly interesting.

1 Like

Ideally, Sage should have composer.json file and be submitted to or so you could just require it in your Bedrock’s composer.json file as a dependency.

However, I don’t see any composer.json being in Sage. Luckily, there seems to be another option. You can use 3rd party plugins (or themes?) as composer packages. Follow this tutorial and let us know if that worked. It’s currently written for WordPress 3rd party plugins, that’s why I’m asking.

Well the problem is, if I pull down Sage, I won’t get my customizations. I’ve basically forked Sage for my own theme, but I’d like to be able to do a git fetch to pull down any upstream fixes. I don’t want to just pull in Sage, but rather be able to git fetch and then merge the upstream to my own changes :slight_smile:

You can use "type": "wordpress-theme" to install themes via Composer as well. Check out to get an idea of it.

So you could have a repo with just your theme and pull it in via Composer. However, if you need to have that theme in a private repo, for a client most likely, it gets a little more complicated. You’ll need to either be able to have all your dev’s computers, as well as your staging and production server be able to access Github/Bitbucket/private Git server, or else set up your own Composer package:

I also don’t know if you necessarily need to keep every change made to Sage incorporated in your theme, since it’s a starter theme and made to build your own theme with it, not necessarily on top of it like a theme framework. You could potentially git cherry-pick commits or else just copy-paste any updates you need into your theme.

Yup. I’m already using Composer in Bedrock for all my plugins management. And in this particular case, the modified theme doesn’t need to be in a private repo (luckily) which makes life a little easier.

I understand that it’s not a “framework”, but when there are fixes/improvements to the base (for example, the recent change for moving GA-Analytics into Soil, etc) I’d like to be able to incorporate them. I think that the copy-pasta route actually probably works fairly well (based upon me having a local copy of the “pure” Sage repo and then just looking at the particular fixes as I need them).

That works. Probably easier to look at the actual commits though

Oh, I would look at the commits. I’m just saying if I have a local repo I can fetch from, then I merge it in and it’s easier to locally diff :slight_smile:

Awesome :slight_smile:
aaaand 20 chars

I’ve asked the same question, but what I’ve managed is:

  • Make changes in the standalone theme directory, and push them to its repo.
  • Run composer update inside Bedrock, and push those changes to Bedrock repo
  • Deploy

It works, but feels a bit unwieldy.