Replace any X with your information.
Of course there is the roots discourse thread from December, but it has issues in different ways, either overwrites local changes or creates merge conflicts for every single change. I imagine other people have issues also, I think we should come up with a solution to his issue with the subtrees.
@TangRufus You have been doing some great work recently, any ideas? Or how did you setup your project(s)?
More less the same as the subtrees method, but:
.git despite the doc tells you to delete it$ git clone -o roots https://github.com/roots/trellis.git www-example-com-trellis
$ cd www-example-com-trellis
$ git remote add tangrufus https://github.com/tangrufus/trellis.git
$ hub create -p
$ git remote -v
origin https://github.com/TangRufus/www-example-com-trellis.git (fetch)
origin https://github.com/TangRufus/www-example-com-trellis.git (push)
roots https://github.com/roots/trellis.git (fetch)
roots https://github.com/roots/trellis.git (push)
tangrufus https://github.com/tangrufus/trellis.git (fetch)
tangrufus https://github.com/tangrufus/trellis.git (push)
## Merge my project temaplate
$ git fetch --all
$ git merge tangrufus/project-template
## Do your job...
## Commit and push to `origin` as usual
## When roots/trellis has been updated...
## Important: Reading change logs, commit messages and `git diff` are necessary
## Tips: Make use of git branches
$ git fetch --all
$ git merge roots/master
No. Use it only if you are comfortable with git. Otherwise, git gives you more headache than benefits.
Yes! Always!
This is actually missing from the doc: the doc tells you to delete .git but gives no instructions about updating.
However, updating Trellis is challenging, I don't think of a good and easy way that suitable for everyone.
Edit: By forks, I mean both origin and tangrufus remotes in the above example.
Since I use git a bit differently than the subtrees method, I got less merge conflicts.
Tips:
roles/*group_vars/<env>/xxx.ymlroles/*role and add it into dev.yml / server.ymlLet say you want to change something in sites-available/example.com.conf:
group_vars/<env>/xxx.yml{{ nginx_path }}/includes.d/{{ item.key }}/xxx.conf but beware Trellis might delete your files during this task, see how I do itgit diff are necessaryGet it merged into roots/trellis
And just to confirm you create a second repo just for bedrock and the
actual WP related stuff?
Correct.
For every project, I have 2 git repo:
You need to change group_vars/<env>/wordpress_sites.yml accordingly
Of course there is the roots discourse thread from December, but it has issues in different ways, either overwrites local changes or creates merge conflicts for every single change
If you make changes to Trellis as @TangRufus outlined, merge conflicts and overwritten local changes shouldn't happen too much.
One thing which I don't know has been mentioned on on Discourse is specifying merge strategies for specific sub paths.
So if you know that roles/ is free of local changes, you can run git merge -X theirs subtree=trellis/roles --squash trellis/master (or something like that).
-X theirs means git will automatically pick every change from trellis/master without prompting for conflicts. ours does the reverse which can be useful for certain files/dirs.
We definitely need some guides/docs about:
I believe it is -X ours not yours, I'll definitely follow Tang's plan
in the future, it'd probably be a headache for my pre-existing ones.
Correct, updated it
@TangRufus Hey Tang, I've almost wrapped up a setup according to your specs, except I'm stuck on a nginx-includes situation. Basically I want to add location blocks to remote servers, in my case one file to do browser caching and another to disable logging for the favicon.
I feel like browser caching should be added into Trellis and enabled when we enable cache. Thoughts? @swalkinshaw
We can't really do that automatically. Just because you enable fast-cgi caching doesn't mean you have a proper setup with asset digests.
Super sorry @swalkinshaw I was just reading other the tickets about browser caching, forgot that you have some concerns with browser caching.
Couldn't we make a "child config" from the base roots config?
It works so well with themes 😄
@TangRufus I've been using your method for a current project and it works great. Two notes though.
It can be slightly simplified by your project's trellis having two remotes not three, one being origin and the second being your user's trellis. You would just keep project-template up-to-date and rebase off of that instead of roots remote.
And the second one is a question. Any idea how to keep bedrock up-to-date without having to deal with merge conflicts for composer.lock?
deal with merge conflicts for composer.lock?
You don't. First resolve conflicts in composer.json, then $ composer update. Let composer generates a new composer.lock for you.
Yup that's what I do. I know it's best practice to keep composer.lock in
vc, but I wonder if it'll work fine without it being in vc. Especially
since it's wp packages and not anything with other Composer dependencies.
On Sun, Dec 3, 2017, 7:01 PM Tang Rufus notifications@github.com wrote:
deal with merge conflicts for composer.lock?
You don't. First resolve conflicts in composer.json, then $ composer
update. Let composer generate a new composer.lock for you.—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/roots/trellis/issues/883#issuecomment-348848791, or mute
the thread
https://github.com/notifications/unsubscribe-auth/ACbIG0vR9isVNOYp62U5IAn_8HuayeBmks5s82CMgaJpZM4PSJjF
.>
Thank you,
Patrick Artounian
It works without composer.lock. However, the deployment will be a little bit different. Trellis may _silently_ upgrade your wp core / plugins / themes during deploy.
Trellis runs $ composer install during deploy.
$ composer install with .lock always install the exact versions listed.
$ composer install without .lock works as $ composer update.
If you really want to exclude .lock from git, always specify the exact package versions in composer.json. Otherwise, trellis will _silently_ upgrade your wp core / plugins / themes during deploy.
Commiting your composer.lock is the best practice.
Use the workaround only if you have a very strong reason.
See:
Yup, that is what I thought. I actually always specify the exact version, as not all minor versions can be without breaking changes.
deal with merge conflicts for composer.lock?
You don't. First resolve conflicts in
composer.json, then$ composer update. Let composer generates a newcomposer.lockfor you.
To avoid unintentionally upgrading packages, use composer update --lock instead. This will only update the lock file.
Most helpful comment
> How did you setup your projects?
More less the same as the
subtreesmethod, but:.gitdespite the doc tells you to delete itDo I recommend everyone to use this method?
No. Use it only if you are comfortable with
git. Otherwise,gitgives you more headache than benefits.Should you always keep your forks update with roots/trellis?
Yes! Always!
This is actually missing from the doc: the doc tells you to delete
.gitbut gives no instructions about updating.However, updating Trellis is challenging, I don't think of a good and easy way that suitable for everyone.
Edit: By forks, I mean both
originandtangrufusremotes in the above example.Avoiding merge conflicts
Since I use
gita bit differently than thesubtreesmethod, I got less merge conflicts.Tips:
roles/*group_vars/<env>/xxx.ymlroles/*roleand add it intodev.yml/server.ymlLet say you want to change something in
sites-available/example.com.conf:group_vars/<env>/xxx.yml{{ nginx_path }}/includes.d/{{ item.key }}/xxx.confbut beware Trellis might delete your files during this task, see how I do it⚠️
git diffare necessaryThe ultimate way to avoid merge conflict
Get it merged into roots/trellis