Skip to content

Instantly share code, notes, and snippets.

@koraysels
Last active November 15, 2021 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koraysels/ccd0cce8e13030233b848345dd7698d3 to your computer and use it in GitHub Desktop.
Save koraysels/ccd0cce8e13030233b848345dd7698d3 to your computer and use it in GitHub Desktop.
Create a trellis project from existing bedrock repos
#!/bin/sh
#change de URL of the repo
deployRepo=https://github.com/undefinedio/deveerman-trellis.git
bedrockRepo=https://github.com/undefinedio/deveerman-backend.git
tools=(trellis) #tool from roots.io
subtrees=(trellis) #folder structure for the tools
#init repo
git init
git remote add origin ${deployRepo}
touch .gitignore
echo "/create_trellis_project.sh" > .gitignore
echo "/.DS_Store" > .gitignore
echo "/.idea" > .gitignore
git add .
git commit -m "initial commit"
#create the project
count=0
for tool in ${tools[@]}; do
git remote add ${tool} https://github.com/roots/${tool}.git
git fetch ${tool}
git checkout -b ${tool} ${tool}/master
git checkout master
git subtree add --prefix=${subtrees[$count]} ${tool} master --squash
git commit -m "add ${tool} subtree"
# git push origin master
count=$(( $count + 1 ))
done
git remote add site ${bedrockRepo}
git fetch site
git stash
git checkout -b site site/master
git checkout master
git subtree add --prefix=site site master --squash
git commit -m "add site subtree"
EOF
# update subtree for the site
# git subtree pull --prefix=site/ site master --squash
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment