Create a Roots Project Working with Git Subtrees

Repo example

I created this bash script that initialize a Roots based project, using Trellis, Bedrock and Sage. Working with Git Subtrees

Run on the project folder:

#change de URL of our initialized repo

#tool from 
tools=(trellis bedrock sage) 

#folder structure for the tools
subtrees=(trellis site site/web/app/themes/sage) 

#init repo
git init
git remote add origin ${repo}
touch .gitignore
git add .
git commit -m "initial commit"

#create the project
for tool in ${tools[@]}; do
  git remote add ${tool}${tool}.git
  git fetch ${tool}
  git checkout -b ${tool} ${tool}/master
  git checkout master
  git read-tree --prefix=${subtrees[$count]}/ -u ${tool}/master
  git commit -m "add ${tool} subtree"
  git push origin master
  count=$(( $count + 1 ))

To keep our projects updated easily

Update Trellis example:

git checkout trellis
git pull 
git checkout master 
git merge -X subtree=trellis/ --squash trellis/master 
git commit -m "Update trellis from trellis/master"

Update Sage example:

git checkout sage
git pull 
git checkout master 
git merge -X subtree=site/web/app/themes/sage/ --squash sage/master 
git commit -m "Update sage from sage/master"

Please see this post which mentioned a issue and fix for fatal: refusing to merge unrelated histories issue: Best practices to update Trellis