Best practices to update Trellis

Has anyone tried git subtree for this? I just updated my project to use this by doing the following:

git remote add trellis https://github.com/roots/trellis.git
mv trellis trellis-old
git commit -a -m 'Moved trellis to prepare for new subtree setup'
git subtree add --prefix=trellis trellis master --squash

Now trellis is at trellis/ via the git subtree feature, which will be helpful later…

But first you have to copy over all your modifications to trellis from trellis-old.

git diff-tree -r -p HEAD:trellis HEAD:trellis-old

will show you what has changed.

git diff-tree -r -p HEAD:trellis HEAD:trellis-old --name-status

will give you a list of changed files. Decide which ones you actually changed vs. what may have changed in the trellis master. I used my text editor to assemble a list of files I actually wanted to copy in ~/tmp/script.sh, then ran it.

bash ~/tmp/script.sh
git add .
git commit -a -m 'Copied trellis customizations from trellis-old folder'

Then cleanup

rm -rf trellis-old
git commit -a -m 'Removed old trellis dir'

Later, if you want to see how your trellis differs from the latest main branch,

git fetch trellis master
git diff trellis/master HEAD:trellis --name-status

And the coup de grace, when you want to do an update, it’s as easy as:

git subtree pull --prefix=trellis trellis master --squash
17 Likes