Best practices to update Trellis


#1

This may seem like a bit of a simpleton-ish question, but what is the best practice to update Trellis with the latest upstream updates from the developers? I cloned Trellis and followed the example project setup a site, and that is in a private GitHub repo now. Since I removed the .git folders as the docs suggest, it doesn’t have an upstream tie anymore. I need to get some updates from the upstream development into mine to fix some issues that have been resolved in newer code. What’s the best way to do this?


Staying up-to-date with Sage 9 changes
How to update Trellis?
Trellis Adds Let's Encrypt Integration
Deploy Clone Project Files dictionary error
Successful provision, failing deployment; can't connect to database
#2

We tell people to remove .git so they can they initialize their own repo. So it should be a Git repo, just your own. After that there’s really only one way to keep it up to date.

Add another remote which is the upstream Trellis and then manually merge/rebase/cherry-pick commits that you want. You’ll need to deal with merge conflicts manually but hopefully there won’t be many unless you’ve heavily customized it.


#3

Is it possible to target the upstream/new remote to a specific folder in the repo?

If no, i was thinking to:

  • create a new repo for updates only
  • clone new/updated trellis/bedrock/sage to the directories my project has (site/, trellis/ etc.)
  • remove .git/ folders in those
  • assign this repo as the upstream and pull things
  • manage conflicts and continue work
  • repeat when updates are available

That way i also won’t have all the commits with notes/pushes/pulls and messages added to my own repo etc.


#4

Look into the -X subtree=<dir> option for various Git commands like merges and cherry-pick. It can apply changes to a top level to a sub path like you want.


#5

Could you please expand a little bit on that? Or just add a sequence of commands… Didn’t find more about the subject :confused:


#6

I’ve posted a blog post about using subtrees with trellis/ bedrock/ sage:

using git subtrees

Please take a look and if anyone spots any improvements/ gotchas to this flow please let me know!


How to pull/merge updates from Trellis remote (master) in case of major changes?
Multisite (subdomain) deploy: Wordpress Installed?, PHP Fatal error: require() missing files
Deploy hanging indefinitely at copy project files step
Updating Trellis: SSL Error for 'site_uses_letsencrypt'
#7

Thanks chrisk2020 :smile: Looks like a different technique and pretty strightforward to follow!


#8

Set this up in a test environment and I like the methodology.

How do you manage multiple sites per Trellis server? As it stands, commits to say site1, site2 and site3 are all lumped together in one overall repository.


#9

I’ll be honest - it’s not something I’ve yet encountered - so don’t yet have a solution. I usually have only one site, client, repo, per DO droplet/ trellis server.

In your use case is it a multisite install or are site1, site2, site3 completely separate?


#10

The latter, three separate standalone sites. Like I say, just a test Vagrant instance but I have a few production VPSs where there is more than one site. Having said that, I’m moving towards the one site per VPS option myself anyway.


#11

Re-visiting this topic as I’ve run into a little issue with the methodology in the post by @chrisk2020 (link above).

I had occasion to update Trellis yesterday and when I did so like this:

$ git checkout trellis $ git pull $ git checkout master $ git merge --squash -s subtree --no-commit trellis $ git commit -m "Update trellis from trellis/master"

…all local changes in my repo were overwritten, leaving me with a fresh vanilla Trellis. This StackOverflow topic is pretty similar to what’s happening to me.

The solution in the linked topic seems a bit inelegant. Any thoughts @chrisk2020?


#12

git merge should give you conflicts that you’d need to resolve manually. Maybe --squash or --no-commit is suppressing that but not sure off the top of my head.


#13

I haven’t done a merge like that before. I have cherry picked commits to keep my project synced up, that seems to work pretty well, and like Scott mentioned, if there are any issues you will have to resolve a merge conflict, which will allow you to preserve your project’s updates.


#14

@kalenjohnson That’s the thing, there aren’t any merge conflicts because the merge overwrites everything automatically. I’m left with a vanilla Trellis.

I’ll keep sniffing round :slight_smile:


#15

I’ve never seen that happen automatically… usually you’d have to explicit set a strategy using -X theirs (meaning “for conflicts use theirs as the winner”).


#16

Hi - @swalkinshaw is correct in that you should (and I do) get notification that merge conflicts should be updated:

Automatic merge failed; fix conflicts and then commit the result.


#17

It does look like the update method needs investigation - I’ve just run through the process on a test repo on trellis/bedrock/sage branches and the branches seem to be over writing each other. Ie. update the ‘bedrock’ branch and the sage files are deleted. I’ll look into it more thoroughly.

EDIT - I found that I had to use a more specific command for the git merge step:

git merge -X subtree=trellis/ --squash trellis/master

and then manually resolve any resulting conflicts.

obviously likewise:

git merge -X subtree=site/ --squash bedrock/master


#18

@chrisk2020 I’m running into the composer fail error above and I think that I definitely need to update trellis because the fix was pushed in only two days ago. However, I’m really not that smart and I don’t understand the git commands that I need to use. Any chance you could explain it to me? I think I need to add a new remote, cherry pick the commit I want, merge into my repo?..I’m confused…:frowning:


#19

what exactly is the message you are getting?


#20

I was following your blog post and when I ran “git read-tree --prefix=trellis/ -u trellis/master” I got “error: Entry ‘trellis/.editorconfig’ overlaps with ‘trellis/.editorconfig’. Cannot bind.”