I tried searching for a discussion about this on here and came up with nothing, if this has been covered please link me! I did find this thread: How to update to latest Sage without losing work but not exactly what I’m trying to do.
I currently keep a fork of Sage 8, with a set of changes, a style guide and some template files (I built a small ‘layout composer’ using ACF) and some other stuff I use in every project.
When building a client site, my process is as follows:
- Create a Bedrock project via composer
- Start a git repo at the top level of bedrock (so /.git/ is in the root, along with .env and /web/ etc.)
- Install Sage 8 in /web/app/themes/sage by cloning my Sage 8 fork
- Delete the /web/app/themes/sage/.git/ directory and commit sage into my main repo.
- Develop my theme.
Occasionally, between projects… I will resync some of the latest changes from Sage 8 into my fork, but I don’t have a set method for doing this. Sometimes I git merge stuff in and deal with the conflicts, sometimes I just check the commits and copy and paste in things.
I’m currently adopting Sage 9 (loving it so far!), and was just wondering if other people are working similar to this and how you deal with resyncing important changes from Sage 9’s main branch?
From my project specific git repo that starts at the root of Bedrock, I can do some kind of git merge that pulls the Sage 9 upstream into the /web/app/themes/sage directory, and lets me deal with the merge conflicts.
I feel like it may be my basic Git skills letting me down! Can anyone suggest anything or point in the right direction?
Hey @mikesource - your current approach is probably as good as any. I suspect that most people don’t generally update their Sage themes from upstream unless there’s a specific change or fix they need to incorporate. Sage isn’t really designed that way (see Keeping Sage Updated). Doing a merge, manually copying changes, or cherry picking commits are likely the best options.
Yep that method works okay, I like @kalenjohnson’s suggestion in that thread, but what I’m asking is whether anyone here has a setup for their git repo similar to mine.
Where Kalen says “I would suggest adding the Sage repo as another git repo on your project”, I can’t do this in my case as the Sage repo starts at a different root directory to my Bedrock initiated repo. I hope I’m making sense. I have a feeling you can set up git to use submodules which I don’t fully understand and from memory it can be a bit fiddly.
Quite prepared to experiment myself but was interested what the Roots community would have to say on the matter
That’s what the
Xsubtree flag is for in
git cherry-pick -Xsubtree=site/web/app/themes/sage, you’re pointing the repo to the folder where it should work on.
Ahaaaa okay, sorry penny dropped now. I think this is what I was after!
Slightly more complicated, but would basically be the holy grail for me, so worth an ask: do you know any way to configure git to cherry-pick commits from a subtree periodically, but always omit certain files/directories??
e.g. merge x commit from upstream but ignore /resources/views/*
kind of like a .gitignore but just for the subtree and the commits you’re pulling from there?